Subject: bug#73181: guix-daemon fails when invoking ‘guix authenticate’ on the Hurd

From: <[email-masked]>
Date: Tue, 05 Nov 2024 12:26:37 +0100

Ludovic Courtès writes:

Hello,

> <[email-masked]> skribis:
>
>> Ludovic Courtès writes:

[..]

>>> I see several possible things to do:
>>>
>>>   1. Disable GC warnings altogether in Guix by setting ‘GC_warn_proc’.
>>>
>>>   2. Make sure guix-daemon discards stderr from agents such as ‘guix
>>>      authenticate’.
>>>
>>>   3. Figure out why those “Repeated allocation” messages are so frequent
>>>      on i586-gnu and Do Something About It™.

[..]

> Yeah, let’s start with (1), maybe with the patch below (untested)?
>
> (2) and (3) would be nice, but it goes with increasing difficulty.

So...find two patches attached.  A tested version of (untested) which
was very helpful but did not compile.  I should have tested with #if 1,
and use #:tests? #f with guix right away... ;)

Anyway, using this patch 0001 it seems that suppressing the warnings
works, I no longer get

--8<---------------cut here---------------start------------->8---
"GC Warning: Repeated allocation of very large block (appr. size 112 KiB):\n\tMay lead to memory leak and poor performance\n"
--8<---------------cut here---------------end--------------->8---

but still get

--8<---------------cut here---------------start------------->8---
unexpected build daemon error: stoi
--8<---------------cut here---------------end--------------->8---

and the copy (and offload) still fails.  Then I tried resetting LC_ALL

>> How about
>>
>>    0. Unsetting LC_ALL on the Hurd
>>
>> would that work?
>
> I’m not sure, but if it does, it’s only “by chance”.

(option 0.) anyway in a followup patch.  Adding this patch 0003 (patch
0002 was just the guix package update), also the "stoi" warning is gone,
and offloading works.

So it seems that we have a workaround that "works by chance", WDYT?

Greetings,
Janneke

>From 3d399e51104171ad328bea66ebdc1d6b0ac99685 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Janneke Nieuwenhuizen <[email-masked]>
Date: Mon, 4 Nov 2024 14:54:55 +0100
Subject: [PATCH 1/3] guile: Silence GC warnings on the Hurd.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8

This should work around <https://issues.guix.gnu.org/73181>, resurrecting
offloading to the Hurd.

* gnu/packages/aux-files/guile-launcher.c (no_warnings)[__GNU__]: New
function.
(main)[__GNU__]: Use it to silence libgc warnings.

Co-authored-by: Ludovic Courtès <[email-masked]>.
Change-Id: I8f30732d192ce46144da4a1a081813a104a5f376
---
 gnu/packages/aux-files/guile-launcher.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/aux-files/guile-launcher.c b/gnu/packages/aux-files/guile-launcher.c
index ad0094bff5..bc7fa21b63 100644
--- a/gnu/packages/aux-files/guile-launcher.c
+++ b/gnu/packages/aux-files/guile-launcher.c
@@ -1,7 +1,8 @@
 /* GNU Guix --- Functional package management for GNU
    Copyright 1996-1997,2000-2001,2006,2008,2011,2013,2018,2020,2021
       Free Software Foundation, Inc.
-   Copyright (C) 2020 Ludovic Courtès <[email-masked]>
+   Copyright (C) 2020, 2024 Ludovic Courtès <[email-masked]>
+   Copyright (C) 2024 Janneke Nieuwenhuizen <[email-masked]>
 
    This file is part of GNU Guix.
 
@@ -28,6 +29,14 @@
 #include <locale.h>
 #include <libguile.h>
 
+#if defined __GNU__
+#include <gc.h>
+static void
+no_warnings (char *message, GC_word arg)
+{
+}
+#endif
+
 /* Saved values of GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH.  */
 static const char *load_path, *load_compiled_path;
 
@@ -73,6 +82,14 @@ main (int argc, char **argv)
        which is always preferable over the C locale.  */
     setlocale (LC_ALL, "en_US.utf8");
 
+#if defined __GNU__
+  /* XXX: On 32-bit GNU/Hurd (i586-gnu), libgc emits "Repeated allocation"
+     warnings that are annoying and interfere with communications between
+     'guix-daemon' and 'guix authenticate':
+     <https://issues.guix.gnu.org/73181>.  Silence them.  */
+  GC_set_warn_proc (no_warnings);
+#endif
+
   const char *str;
   str = getenv ("GUILE_LOAD_PATH");
   load_path = str != NULL ? strdup (str) : NULL;

base-commit: 20c7b8dd04e421a139a02438cf1ddfdfe544a446
-- 
Janneke Nieuwenhuizen <[email-masked]>  | GNU LilyPond https://LilyPond.org
Freelance IT https://www.JoyOfSource.com | Avatar® https://AvatarAcademy.com

>From b62d59cf5cc9f968bedd8126f587bc8e14f7964c Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
In-Reply-To: <[email-masked]>
References: <[email-masked]>
From: Janneke Nieuwenhuizen <[email-masked]>
Date: Mon, 4 Nov 2024 17:38:46 +0100
Subject: [PATCH 3/3] squash! guile: Silence GC warnings on the Hurd.
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8

Change-Id: Ia720221ed285d3e56938cfa37989d2c7c07b00e3
---
 gnu/packages/aux-files/guile-launcher.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/aux-files/guile-launcher.c b/gnu/packages/aux-files/guile-launcher.c
index bc7fa21b63..ee6da76cc4 100644
--- a/gnu/packages/aux-files/guile-launcher.c
+++ b/gnu/packages/aux-files/guile-launcher.c
@@ -75,19 +75,22 @@ inner_main (void *unused, int argc, char **argv)
 int
 main (int argc, char **argv)
 {
-  /* Try to install the current locale; remain silent if it fails.  */
-  if (setlocale (LC_ALL, "") == NULL)
-    /* The 'guix pull'-provided 'guix' includes at least en_US.utf8 so use
-       that.  That gives us UTF-8 support for 'scm_to_locale_string', etc.,
-       which is always preferable over the C locale.  */
-    setlocale (LC_ALL, "en_US.utf8");
-
 #if defined __GNU__
+  /* Try to install the C locale; remain silent if it fails.  */
+  setlocale (LC_ALL, "C");
+
   /* XXX: On 32-bit GNU/Hurd (i586-gnu), libgc emits "Repeated allocation"
      warnings that are annoying and interfere with communications between
      'guix-daemon' and 'guix authenticate':
      <https://issues.guix.gnu.org/73181>.  Silence them.  */
   GC_set_warn_proc (no_warnings);
+#else
+  /* Try to install the current locale; remain silent if it fails.  */
+  if (setlocale (LC_ALL, "") == NULL)
+    /* The 'guix pull'-provided 'guix' includes at least en_US.utf8 so use
+       that.  That gives us UTF-8 support for 'scm_to_locale_string', etc.,
+       which is always preferable over the C locale.  */
+    setlocale (LC_ALL, "en_US.utf8");
 #endif
 
   const char *str;
-- 
Janneke Nieuwenhuizen <[email-masked]>  | GNU LilyPond https://LilyPond.org
Freelance IT https://www.JoyOfSource.com | Avatar® https://AvatarAcademy.com

-- 
Janneke Nieuwenhuizen <[email-masked]>  | GNU LilyPond https://LilyPond.org
Freelance IT https://www.JoyOfSource.com | Avatar® https://AvatarAcademy.com