Subject: bug#42047: [PATCH v2] guix: gc: Support for the Hurd.

From: Jan Nieuwenhuizen <[email-masked]>
Date: Sat, 27 Jun 2020 13:25:13 +0200

Jan Nieuwenhuizen writes:

Hello,

>> Nitpick: I see 3 mostly unrelated patches: (1) fix duplicate called to
>> ‘scope’, (2) mount /proc, and (3) handle EIO.  I think it’s clearer to
>> view them separately.

> Yes, I agree.  I will split into 3 patches.

I have split and pushed the trivial hurd-boot patches as
65d95e5d852e47343b9acc1717918c9db7364c01

>>>    (append-map rhs-file-names
>>> -              (split-on-nul
>>> -               (call-with-input-file environ
>>> -                 get-string-all))))
>>> +              (catch 'system-error
>>> +                (lambda _
>>> +                  (split-on-nul
>>> +                   (call-with-input-file environ
>>> +                     get-string-all)))
>>> +                (lambda args
>>> +                  (if (= EIO (system-error-errno args))
>>> +                      '()
>>> +                      (apply throw args))))))
>>
>> This may be papering over a real problem.  Before doing that, I think
>> “we” :-) should investigate why procfs returns EIO in some cases and
>> look into fixing it.
>
> Sure, let "us" look into that! :)

I have (with some kind fixup help from Marius) created a gdb-minimal
package that cross-builds and works on the Hurd.  I tried to gain
insight by attaching to guix-daemon or just running guix-daemon in gdb,
but it does not seem to run under gdb; but that could be my
inexperience.  I'm only getting mig/ipc or thread messages...

So...attached is a pretty blunt hack that does "fix" guix gc.  Where the
above "tried" to paper over the problem, "catch #t" is the only thing I
could get to actually work.

I'm really puzzled here.  This

--8<---------------cut here---------------start------------->8---
  (append-map rhs-file-names
              (split-on-nul
               (catch #t ;;'system-error
                 (lambda _
                   (call-with-input-file environ
                     get-string-all))
                 (lambda args
                   (format (current-error-port) "KETS: args=~s\n" args)
                   (format (current-error-port) "sys: ~s\n" (system-error-errno args))
                   ""))))
--8<---------------cut here---------------end--------------->8---

gives

--8<---------------cut here---------------start------------->8---
KETS: args=(r6rs:exception #<r6rs:record:&raise-object-wrapper>)
sys: #f
Backtrace:
          19 (apply-smob/1 #<catch-closure 4003b0>)
In ice-9/boot-9.scm:
    705:2 18 (call-with-prompt _ _ #<procedure default-prompt-handler (k proc)>)
In ice-9/eval.scm:
    619:8 17 (_ #(#(#<directory (guile-user) 3ec910>)))
In guix/ui.scm:
  1948:12 16 (run-guix-command _ . _)
In ice-9/boot-9.scm:
    829:9 15 (catch _ _ #<procedure 5f5df8 at guix/ui.scm:662:2 (key c)> _)
    829:9 14 (catch _ _ #<procedure 5f5e08 at guix/ui.scm:796:6 (key proc format-string format-args . rest)> _)
In guix/scripts/gc.scm:
   280:14 13 (_)
In guix/store/roots.scm:
   290:39 12 (busy-store-items)
madvise failed: Function not implemented
In srfi/srfi-1.scm:
   679:15 11 (append-map _ _ . _)
   592:29 10 (map1 _)
   592:29  9 (map1 _)
   592:29  8 (map1 _)
   592:29  7 (map1 _)
   592:29  6 (map1 ("5" "6" "7" "9" "10" "12" "19" "23" "24" "25" "26" "27" "42" "93" "95" "109" "197" "503" …))
   592:29  5 (map1 ("6" "7" "9" "10" "12" "19" "23" "24" "25" "26" "27" "42" "93" "95" "109" "197" "503" "5…" …))
   592:29  4 (map1 ("7" "9" "10" "12" "19" "23" "24" "25" "26" "27" "42" "93" "95" "109" "197" "503" "516" # …))
   592:17  3 (map1 ("9" "10" "12" "19" "23" "24" "25" "26" "27" "42" "93" "95" "109" "197" "503" "516" "538" …))
In ice-9/boot-9.scm:
    829:9  2 (catch system-error #<procedure 3846800 at guix/store/roots.scm:254:20 ()> #<procedure 3d28048 a…> …)
In guix/store/roots.scm:
   259:30  1 (_)
   204:15  0 (proc-environ-roots _)

guix/store/roots.scm:204:15: In procedure proc-environ-roots:
ERROR: R6RS exception:
  1. &i/o-read
  2. &i/o-port: #<input: /proc/9/environ 13>
--8<---------------cut here---------------end--------------->8---

which shows 'system-error as well as conditions.  But using "catch
'system-error' or even

--8<---------------cut here---------------start------------->8---
 (append-map rhs-file-names
             (split-on-nul
              (guard (c (else ;;(i/o-read-error? c)
                         (format #t "KETS\n")
                         (format (current-error-port) "KETS\n")
                         (format (current-error-port) "~a: ignoring EIO: Good luck!\n" environ)
                         "")
                        ;; (#t
                        ;;  (format (current-error-port) "~a: DUNNO\n" c)
                        ;;  "")
                        )
                (format (current-error-port) "gonna call\n")
                (call-with-input-file environ
                  get-string-all))))
--8<---------------cut here---------------end--------------->8---

shows no debug printing at all except "gonna call", and the
exception/condition/raisy-thing somehow "escapes".

Greetings,
Janneke

>From 751423e35e9b4b30e066de9ae6305748fd8f3b0d Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" <[email-masked]>
Date: Thu, 25 Jun 2020 17:07:25 +0200
Subject: [PATCH v2] guix: gc: Support for the Hurd.

* guix/store/roots.scm (proc-environ-roots): Handle EIO, for the Hurd.
---
 guix/store/roots.scm | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/guix/store/roots.scm b/guix/store/roots.scm
index 58653507f8..ad4f111b79 100644
--- a/guix/store/roots.scm
+++ b/guix/store/roots.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2017, 2019 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -24,6 +25,9 @@
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-34)
+  #:use-module (srfi srfi-35)
+  #:use-module (rnrs exceptions)
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
   #:use-module (ice-9 rdelim)
@@ -198,8 +202,13 @@ or the empty list."
 
   (append-map rhs-file-names
               (split-on-nul
-               (call-with-input-file environ
-                 get-string-all))))
+               (catch #t
+                 (lambda _
+                   (call-with-input-file environ
+                     get-string-all))
+                 (lambda args
+                   (format (current-error-port) "~a: ignoring EIO: Good luck!\n" environ)
+                   "")))))
 
 (define (referenced-files)
   "Return the list of referenced store items."
-- 
Jan Nieuwenhuizen <[email-masked]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

-- 
Jan Nieuwenhuizen <[email-masked]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com