Subject: Re: bug#47172: Shepherd 0.8.1 tests fail on core-updates

From: Ludovic Courtès <[email-masked]>
Date: Sun, 23 May 2021 12:25:27 +0200

Hi there,

Léo Le Bouter <[email-masked]> skribis:

> Some tests fail:
>
> FAIL: tests/no-home.sh
> FAIL: tests/status-sexp.sh
> PASS: tests/misbehaved-client.sh

[...]

> It seems this is due to guile 3.0.5, GNU Shepherd 0.8.1 does not work
> with it, it works with guile 3.0.2 however.

This turns out to be due to a… miscompilation bug.

In (shepherd scripts herd), ‘run-command’ has this code:

  (let ((sock    (open-connection socket-file))
        (action* (if (and (eq? action 'detailed-status)
                          (memq service '(root shepherd)))
                     'status
                     action)))
    …)

Problem is that everything works as if (eq? action 'detailed-status)
was omitted, such that ‘herd stop root’ is interpreted as ‘herd status
root’.

Simply wrapping the condition in (pk …) “fixes” the problem.

The peval output looks good (it contains the 'detailed-status
comparison), but the assembly seems to lack the 'detailed-status
comparison altogether:

--8<---------------cut here---------------start------------->8---
Disassembly of <unnamed function> at #x29e0:

   0    (instrument-entry 15700)                              at shepherd/scripts/herd.scm:127:2
   2    (assert-nargs-ee/locals 1 11)   ;; 12 slots (0 args)
   3    (static-ref 10 15369)           ;; #f                 at shepherd/scripts/herd.scm:128:19
   5    (immediate-tag=? 10 7 0)        ;; heap-object?
   7    (je 9)                          ;; -> L1
   8    (static-ref 10 14166)           ;; #f
  10    (static-ref 9 15372)            ;; open-connection
  12    (call-scm<-scm-scm 10 10 9 111) 
  14    (static-set! 10 15358)          ;; #f
L1:
  16    (scm-ref/immediate 7 10 1)      
  17    (scm-ref/immediate 6 11 2)      
  18    (handle-interrupts)                                   at shepherd/scripts/herd.scm:128:18
  19    (call 4 2)                      
  21    (receive 1 4 12)                
  23    (scm-ref/immediate 9 11 3)      
  24    (static-ref 8 15360)            ;; #f                 at shepherd/scripts/herd.scm:134:6
  26    (immediate-tag=? 8 7 0)         ;; heap-object?
  28    (je 9)                          ;; -> L2
  29    (static-ref 8 14145)            ;; #f
  31    (static-ref 7 15363)            ;; write-command
  33    (call-scm<-scm-scm 8 8 7 111)   
  35    (static-set! 8 15349)           ;; #f
L2:
  37    (scm-ref/immediate 8 8 1)       
  38    (static-ref 7 15358)            ;; #f                 at shepherd/scripts/herd.scm:134:21
  40    (immediate-tag=? 7 7 0)         ;; heap-object?
  42    (je 9)                          ;; -> L3
  43    (static-ref 7 14131)            ;; #f
  45    (static-ref 6 15361)            ;; shepherd-command
  47    (call-scm<-scm-scm 7 7 6 111)   
  49    (static-set! 7 15347)           ;; #f
L3:
  51    (scm-ref/immediate 7 7 1)       
  52    (scm-ref/immediate 6 11 4)      
  53    (static-ref 5 15363)            ;; root
  55    (eq? 6 5)                       
  56    (je 5)                          ;; -> L4
  57    (static-ref 5 13655)            ;; shepherd
  59    (eq? 6 5)                       
  60    (jne 3)                         ;; -> L5
L4:
  61    (static-ref 9 15365)            ;; status             at shepherd/scripts/herd.scm:131:22
L5:
  63    (static-ref 1 15375)            ;; #:arguments        at shepherd/scripts/herd.scm:134:54
  65    (scm-ref/immediate 0 11 5)      
  66    (mov 4 7)                                             at shepherd/scripts/herd.scm:134:20
--8<---------------cut here---------------end--------------->8---

(This is compiled with 3.0.7 and the default optimizations, so -O2.)

To be continued…

Ludo’.