From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id Vho8KFmHHWBQOgAA0tVLHw (envelope-from ) for ; Fri, 05 Feb 2021 17:58:49 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id aNehI1mHHWAGWQAA1q6Kng (envelope-from ) for ; Fri, 05 Feb 2021 17:58:49 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1622D94030E for ; Fri, 5 Feb 2021 17:58:48 +0000 (UTC) Received: from localhost ([::1]:48976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l85NX-0005dS-Eo for larch@yhetil.org; Fri, 05 Feb 2021 12:58:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l84gF-0006ck-7M for bug-guix@gnu.org; Fri, 05 Feb 2021 12:14:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:33085) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l84gE-0001Ur-HR for bug-guix@gnu.org; Fri, 05 Feb 2021 12:14:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l84gE-0007aR-Cq; Fri, 05 Feb 2021 12:14:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#46330: Guile-provided GMP allocators interfere with GnuTLS Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 05 Feb 2021 17:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46330 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 46330@debbugs.gnu.org Received: via spool by 46330-submit@debbugs.gnu.org id=B46330.161254520329081 (code B ref 46330); Fri, 05 Feb 2021 17:14:02 +0000 Received: (at 46330) by debbugs.gnu.org; 5 Feb 2021 17:13:23 +0000 Received: from localhost ([127.0.0.1]:44626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l84fR-0007Yn-K8 for submit@debbugs.gnu.org; Fri, 05 Feb 2021 12:13:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60050) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l84fP-0007YY-6R for 46330@debbugs.gnu.org; Fri, 05 Feb 2021 12:13:12 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:48355) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l84fK-00016C-1C for 46330@debbugs.gnu.org; Fri, 05 Feb 2021 12:13:06 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=36232 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l84fH-0004iD-Gv for 46330@debbugs.gnu.org; Fri, 05 Feb 2021 12:13:04 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <87v9b61md4.fsf@inria.fr> Date: Fri, 05 Feb 2021 18:13:02 +0100 In-Reply-To: <87v9b61md4.fsf@inria.fr> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Fri, 05 Feb 2021 17:59:51 +0100") Message-ID: <87im761lr5.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.85 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: 1622D94030E X-Spam-Score: -2.85 X-Migadu-Scanner: scn1.migadu.com X-TUID: QDyyJ/CZFDlh --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s skribis: > In a nutshell, Guile installs its own GMP memory allocation routines > (when =E2=80=98scm_install_gmp_memory_functions=E2=80=99 is true, which i= s the default) > so that GMP allocates via libgc. GnuTLS uses Nettle, which uses GMP, so > Nettle too ends up allocating via libgc; however, since pointers to that > memory are not scanned by libgc, they end up being reclaimed early. One of the solutions is to set: scm_install_gmp_memory_functions =3D 0; in Guile, as Andy suggested on IRC, but it incurs a performance hit on bignum-heavy applications such as the compiler: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D964284#78 However, since Guix now uses its own =E2=80=98guile=E2=80=99 binary, we can= work around the issue like so: --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/gnu/packages/aux-files/guile-launcher.c b/gnu/packages/aux-fil= es/guile-launcher.c index 1dd5d77e66..814084e032 100644 --- a/gnu/packages/aux-files/guile-launcher.c +++ b/gnu/packages/aux-files/guile-launcher.c @@ -1,5 +1,5 @@ /* GNU Guix --- Functional package management for GNU - Copyright 1996-1997,2000-2001,2006,2008,2011,2013,2018,2020 + Copyright 1996-1997,2000-2001,2006,2008,2011,2013,2018,2020,2021 Free Software Foundation, Inc. Copyright (C) 2020 Ludovic Court=C3=A8s =20 @@ -82,7 +82,10 @@ main (int argc, char **argv) unsetenv ("GUILE_LOAD_PATH"); unsetenv ("GUILE_LOAD_COMPILED_PATH"); =20 - scm_install_gmp_memory_functions =3D 1; + /* XXX: Do not let GMP allocate via libgc as this can lead to memory + corruption in GnuTLS/Nettle: . */ + scm_install_gmp_memory_functions =3D 0; + scm_boot_guile (argc, argv, inner_main, 0); return 0; /* never reached */ } --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable The advantage of this hack is that we still get to use upstream =E2=80=98gu= ile=E2=80=99 for compilation purposes (with no performance hit), and we use our own =E2=80=9Csafe=E2=80=9D =E2=80=98guile=E2=80=99 executable for stuff that ma= y use GnuTLS, in particular =E2=80=98guix substitute=E2=80=99 and =E2=80=98guix perform-download=E2=80= =99. There may still be a few cases where we=E2=80=99d use stock =E2=80=98guile= =E2=80=99 together with GnuTLS. The only example that comes to mind is when calling =E2=80=98download-nar=E2=80=99 or =E2=80=98swh-download=E2=80=99 as a fallb= ack in (guix git-download). That=E2=80=99s quite rare though. So I think that the above is a workaround we could deploy right away. It should allow us to wait until we have Guile on mini-GMP. Thoughts? Ludo=E2=80=99. --=-=-=--