Subject: bug#30155: 'bag-transitive-inputs' behaves non-deterministically

From: [email-masked] (Ludovic Courtès)
Date: Thu, 18 Jan 2018 12:20:38 +0100

On ‘core-updates’ (e80514bc03b003a7ce95d7b55cf33c9f18f9e860) I get:

--8<---------------cut here---------------start------------->8---
ludo@ribbon ~/src/guix/+core-updates$ make -q
make  all-recursive
make[1]: Entering directory '/home/ludo/src/guix/+core-updates'
Making all in po/guix
make[1]: Leaving directory '/home/ludo/src/guix/+core-updates'
ludo@ribbon ~/src/guix/+core-updates$ ./pre-inst-env guix build -e '(@@ (gnu packages commencement) static-bash-for-glibc)'  -d
/gnu/store/xymnr48xhdzvrw0cakhyn7hgapr4wiix-bash-static-4.4.12.drv
ludo@ribbon ~/src/guix/+core-updates$ rm gnu/packages/commencement.go 
ludo@ribbon ~/src/guix/+core-updates$ ./pre-inst-env guix build -e '(@@ (gnu packages commencement) static-bash-for-glibc)'  -d
;;; note: source file /home/ludo/src/guix/+core-updates/gnu/packages/commencement.scm
;;;       newer than compiled /run/current-system/profile/lib/guile/2.2/site-ccache/gnu/packages/commencement.go
;;; note: source file /home/ludo/src/guix/+core-updates/gnu/packages/commencement.scm
;;;       newer than compiled /run/current-system/profile/lib/guile/2.2/site-ccache/gnu/packages/commencement.go
;;; note: source file /home/ludo/src/guix/+core-updates/gnu/packages/commencement.scm
;;;       newer than compiled /run/current-system/profile/lib/guile/2.2/site-ccache/gnu/packages/commencement.go
;;; note: source file /home/ludo/src/guix/+core-updates/gnu/packages/commencement.scm
;;;       newer than compiled /home/ludo/.cache/guile/ccache/2.2-LE-8-3.A/home/ludo/src/guix/+core-updates/gnu/packages/commencement.scm.go
/gnu/store/crzz4z5k8hpdkbgzqvn7bz3rspq13gb5-bash-static-4.4.12.drv
--8<---------------cut here---------------end--------------->8---

The difference between these two derivations is the build script.  In
the second case, it reads this:

--8<---------------cut here---------------start------------->8---
  (define %build-inputs
    (quote
     (("source" . "/gnu/store/hl0xxmm8habnijw7y45dqsp9j5nqxq6i-bash-4.4.tar.xz")
      ("gcc" . "/gnu/store/a1qrh6iw7gj3f8m0d3v97xc4xrk2qbk9-gcc-cross-boot0-wrapped-5.5.0")
      ("libc" . "/gnu/store/b6mcmg1wmxz83hd9ffjwzxv9xdb0xsbm-glibc-intermediate-2.26.105-g0890d5379c")
      ("libc:static" . "/gnu/store/9gy08pnv20v1g1ldmqlsy07lhj2w77gi-glibc-intermediate-2.26.105-g0890d5379c-static")
      ("ld-wrapper-cross" . "/gnu/store/hmb02fkk0gv2j7l3kb4a1igy6cga7kbl-ld-wrapper-boot0-0")
      ("binutils-cross" . "/gnu/store/580ywwc0sr3l4dqj36a5jl5ad3yh760b-binutils-cross-boot0-2.28.1")
      ("make" . "/gnu/store/f7q38v9fh9zz27qinjwscqip8k7fkirs-make-boot0-4.2.1")
      ("diffutils" . "/gnu/store/96brzsaxvax24qwylwfhb2kjikbm3zhn-diffutils-boot0-3.6")
      ("findutils" . "/gnu/store/imjcbzjrp4jsvmrznc8xyhja28jgnflv-findutils-boot0-4.6.0")
      ("file" . "/gnu/store/b18smgaibx4kgbw9sdypdd5x5pxjif5j-file-boot0-5.32")
      ("coreutils&co" . "/gnu/store/wsb8hrijrss858p2ddwmqwg85z8q719c-bootstrap-binaries-0")
      ("bash" . "/gnu/store/wsb8hrijrss858p2ddwmqwg85z8q719c-bootstrap-binaries-0")
      ("kernel-headers" . "/gnu/store/yqahwgll57j88bq275m4xvifg9x3alsb-linux-libre-headers-4.9.59")
      ("kernel-headers" . "/gnu/store/yqahwgll57j88bq275m4xvifg9x3alsb-linux-libre-headers-4.9.59"))))
--8<---------------cut here---------------end--------------->8---

Notice the “kernel-headers” repetition, which is not in the correct
build script.

The repetition stems from the traversal done by ‘bag-transitive-inputs’,
which relies on pointer identity when comparing packages (via the ‘eq?’
vhash in ‘transitive-inputs’), and for some reason there are two non-eq?
linux-libre-headers packages encountered here.  ‘master’ doesn’t have
this problem.

FTR we had a similar issue in <http://bugs.gnu.org/20037> with PAM
services.

Incidentally, I discovered this bug while getting berlin.guixsd.org to
build ‘core-updates’: Cuirass there would exhibit the bug, and thus
berlin would end up building something different from what I have on my
laptop (and what hydra.gnu.org has.)

Ludo’.