Subject: Re: bug#41625: Sporadic guix-offload crashes due to EOF errors

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 24 Sep 2021 00:55:30 -0400

Oh, and for completion, here's a reproducer I used here to debug with my
low power offload machine:

--8<---------------cut here---------------start------------->8---
x(use-modules (guix scripts offload)
             (guix inferior)
             ((guix ssh) #:hide (open-ssh-session))

             (ice-9 match)
             (ssh popen))

(define machine (build-machine
                 (name "tm")
                 (port 22)
                 (user "root")
                 (systems (list "armhf-linux"))
                 ;; ecdsa-sha2-nistp256
                 (host-key "ssh-ecdsa-p256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIx32IqtlUr2VMypLItGSnmKzd0eJkgnzPkVbOZbn4HFQD5KvWB98t4IkT0PESjs+DDQfI/PwRENo3yqd5GjukA=")
                 (parallel-builds 2)
                 (compression "none")
                 (private-key "/home/maxim/.ssh/id_rsa.1")))

(define open-ssh-session (@@ (guix scripts offload) open-ssh-session))

(define session (open-ssh-session machine 15))

(define repl-command '("guix" "repl" "-t" "machine"))

(define pipe (apply open-remote-pipe* session OPEN_BOTH repl-command))

;;; Hangs
;;;(port->inferior pipe)

(define rest (match (read pipe)
               (('repl-version 0 rest ...)
                rest)))

(define %inferior-packages (@@ (guix inferior) %inferior-packages))

(define %inferior-package-table (@@ (guix inferior) %inferior-package-table))

(define inferior (@@ (guix inferior) inferior))
(define inferior-socket (@@ (guix inferior) inferior-socket))

(define result (inferior 'pipe pipe close (cons 0 rest)
                         (delay (%inferior-packages result))
                         (delay (%inferior-package-table result))))

(define send-inferior-request (@@ (guix inferior) send-inferior-request))

(send-inferior-request '(() repl-version 0 1 1) result)

(inferior-eval '(use-modules (guix)) result)

;;; Hangs!
;;t(inferior-eval '(use-modules (gnu)) result)

(send-inferior-request '(use-modules (gnu)) result)

(define socket (inferior-socket result))

;;Throw to key `match-error' with args `("match" "no matching pattern" #<eof>)'
;;(read-repl-response socket result)
;; -> guix using 100% cpu, reading package modules for ~ 1m30s

;;; guile-ssh returns <eof> on timeout? (15 s) -> yes
(read socket)
--8<---------------cut here---------------end--------------->8---

I wish the Guile debugger was more capable; it'd have spared me the
above manual labor :-)

Maxim