GNU bug report logs - #36777
Guix Inferiors: Curious incorrect derivation output bug

Previous Next

Package: guix;

Reported by: Carl Dong <contact <at> carldong.me>

Date: Wed, 24 Jul 2019 01:10:01 UTC

Severity: important

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 36777 in the body.
You can then email your comments to 36777 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#36777; Package guix. (Wed, 24 Jul 2019 01:10:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Carl Dong <contact <at> carldong.me>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Wed, 24 Jul 2019 01:10:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <contact <at> carldong.me>
To: "bug-guix <at> gnu.org" <bug-guix <at> gnu.org>
Subject: Guix Inferiors: Curious incorrect derivation output bug
Date: Wed, 24 Jul 2019 01:09:10 +0000
Hi all,

I've been working on improving the Guix build support on Bitcoin Core so that
it'll be ready to use for official releases.

One of the things that I wanted to do was to use a combination of channels and
inferiors to have reproducible builds across time. I have most of it set up, but
am running into some trouble. Here are the details:

I have a Guix channel set up at https://github.com/dongcarl/bitcoin-guix, where
I pin the Guix version to 6869b6635afd93872b8f0d9f2db0db4c0d765a86 in the
.guix-channel, and declare all my packages in packages.scm.

I have my manifest.scm here:
https://github.com/dongcarl/bitcoin/blob/2019-06-guix-channels-and-inferiors/contrib/guix/manifest.scm,
and it references the aforementioned Guix channel.

What I expect to happen is that now when I change my default profile's Guix
version by 'guix pull'ing, it won't affect the environment that's generated by
the manifest.scm. I've tested this with differing versions of Guix as my default
profile, and this seems to work with 7304d5623ab5cc35289cb1535cbd0d8a37691fac
and 7f1c69f5d32bee6b8b6b902a9ce445e04aa9d07d being my default profile. However,
I tried an older version b6dc08393e6a8313b88ce422fc3c1e4e9c0efc6f, and got the
following error:

```
guix environment: error: derivation `/gnu/store/r641vpqc9rfjhljf7rzfzwmkmpa642ls-info-dir.drv' has incorrect output `/gnu/store/q9hkdidycz3wq28xxgjq47bzx5s39k52-info-dir', should be `/gnu/store/z5hh2nl0h58b9f6hdxfwm00gjyxfcc3n-info-dir'
```

I remember my previous attempts at integrating channels and inferiors into our
workflow yielded a similar result, so I would like to know if this is a bug, and
how I might go about fixing this so that I can feel comfortable using inferiors
for our builds.

Nevertheless, thank you all for your hard work. The fact that we have inferiors
at all is marvelous!

Cheers,
Carl Dong
contact <at> carldong.me
"I fight for the users"




Information forwarded to bug-guix <at> gnu.org:
bug#36777; Package guix. (Fri, 26 Jul 2019 07:51:02 GMT) Full text and rfc822 format available.

Message #8 received at 36777 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: 36777 <at> debbugs.gnu.org
Subject: Re: bug#36777: Guix Inferiors: Curious incorrect derivation output bug
Date: Fri, 26 Jul 2019 09:50:45 +0200
Hello Carl,

Carl Dong <contact <at> carldong.me> skribis:

> I have my manifest.scm here:
> https://github.com/dongcarl/bitcoin/blob/2019-06-guix-channels-and-inferiors/contrib/guix/manifest.scm,
> and it references the aforementioned Guix channel.

This one appears to work for me (I interrupted it before it was done
compiling all the toolchains, though.)

> What I expect to happen is that now when I change my default profile's Guix
> version by 'guix pull'ing, it won't affect the environment that's generated by
> the manifest.scm. I've tested this with differing versions of Guix as my default
> profile, and this seems to work with 7304d5623ab5cc35289cb1535cbd0d8a37691fac
> and 7f1c69f5d32bee6b8b6b902a9ce445e04aa9d07d being my default profile. However,
> I tried an older version b6dc08393e6a8313b88ce422fc3c1e4e9c0efc6f, and got the
> following error:

When I put b6dc08393e6a8313b88ce422fc3c1e4e9c0efc6f in .guix-channel and
use that as my channel, it also works fine (well, I commented out the
toolchains as well.)

> ```
> guix environment: error: derivation `/gnu/store/r641vpqc9rfjhljf7rzfzwmkmpa642ls-info-dir.drv' has incorrect output `/gnu/store/q9hkdidycz3wq28xxgjq47bzx5s39k52-info-dir', should be `/gnu/store/z5hh2nl0h58b9f6hdxfwm00gjyxfcc3n-info-dir'
> ```

That definitely looks like a bug.

Could you send the faulty info-dir.drv file?

Thanks,
Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#36777; Package guix. (Fri, 26 Jul 2019 19:59:01 GMT) Full text and rfc822 format available.

Message #11 received at 36777 <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <contact <at> carldong.me>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: "36777 <at> debbugs.gnu.org" <36777 <at> debbugs.gnu.org>
Subject: Re: bug#36777: Guix Inferiors: Curious incorrect derivation output bug
Date: Fri, 26 Jul 2019 19:58:16 +0000
Hi all,

I did some more digging, and have included a git-bisect log, the -info-dir.drv,
and -info-dir-builder here:

https://gist.github.com/dongcarl/0a305badf20c9b5cfae738147ca416af

Please let me know if I can provide more information.

Cheers,
Carl Dong
contact <at> carldong.me
"I fight for the users"

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, July 26, 2019 7:50 AM, Ludovic Courtès <ludo <at> gnu.org> wrote:

> Hello Carl,
>
> Carl Dong contact <at> carldong.me skribis:
>
> > I have my manifest.scm here:
> > https://github.com/dongcarl/bitcoin/blob/2019-06-guix-channels-and-inferiors/contrib/guix/manifest.scm,
> > and it references the aforementioned Guix channel.
>
> This one appears to work for me (I interrupted it before it was done
> compiling all the toolchains, though.)
>
> > What I expect to happen is that now when I change my default profile's Guix
> > version by 'guix pull'ing, it won't affect the environment that's generated by
> > the manifest.scm. I've tested this with differing versions of Guix as my default
> > profile, and this seems to work with 7304d5623ab5cc35289cb1535cbd0d8a37691fac
> > and 7f1c69f5d32bee6b8b6b902a9ce445e04aa9d07d being my default profile. However,
> > I tried an older version b6dc08393e6a8313b88ce422fc3c1e4e9c0efc6f, and got the
> > following error:
>
> When I put b6dc08393e6a8313b88ce422fc3c1e4e9c0efc6f in .guix-channel and
> use that as my channel, it also works fine (well, I commented out the
> toolchains as well.)
>
> >     guix environment: error: derivation `/gnu/store/r641vpqc9rfjhljf7rzfzwmkmpa642ls-info-dir.drv' has incorrect output `/gnu/store/q9hkdidycz3wq28xxgjq47bzx5s39k52-info-dir', should be `/gnu/store/z5hh2nl0h58b9f6hdxfwm00gjyxfcc3n-info-dir'
> >
>
> That definitely looks like a bug.
>
> Could you send the faulty info-dir.drv file?
>
> Thanks,
> Ludo’.






Information forwarded to bug-guix <at> gnu.org:
bug#36777; Package guix. (Sat, 27 Jul 2019 21:31:02 GMT) Full text and rfc822 format available.

Message #14 received at 36777 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: "36777 <at> debbugs.gnu.org" <36777 <at> debbugs.gnu.org>
Subject: Re: bug#36777: Guix Inferiors: Curious incorrect derivation output bug
Date: Sat, 27 Jul 2019 23:30:04 +0200
[Message part 1 (text/plain, inline)]
Hi Carl,

Carl Dong <contact <at> carldong.me> skribis:

> I did some more digging, and have included a git-bisect log, the -info-dir.drv,
> and -info-dir-builder here:
>
> https://gist.github.com/dongcarl/0a305badf20c9b5cfae738147ca416af

For future reference, the bisect output is:

  # first bad commit: [5cf4b26d52bcea382d98fb4becce89be9ee37b55] derivations: <derivation-input> now aggregates a <derivation>.

and ‘info-dir.drv’ is attached below.

I looked at the offending commit.  I don’t doubt it has the potential to
introduce such a bug :-), but so far I haven’t seen anything fishy as I
inspected it with a fresh eye.

Could you come up with a reduced reproducer for this?  Ideally a small
manifest, the commit of the Guix you’re using (not just that of the
inferior), maybe a manifest that doesn’t even use inferiors, and so on.

Alternately, since the problem is that the output path of the derivation
is incorrectly computed, you could add ‘pk’ calls to print the value of
‘drv-masked’ in (guix derivations) or similar.  That’s not going to be
convenient, though.  :-/

Ludo’.

PS: I’ll be away from keyboard so I won’t be able to look into it until
    some time.

[t.drv (text/plain, attachment)]

Information forwarded to bug-guix <at> gnu.org:
bug#36777; Package guix. (Sat, 27 Jul 2019 21:50:02 GMT) Full text and rfc822 format available.

Message #17 received at 36777 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: "36777 <at> debbugs.gnu.org" <36777 <at> debbugs.gnu.org>
Subject: Re: bug#36777: Guix Inferiors: Curious incorrect derivation output bug
Date: Sat, 27 Jul 2019 23:48:57 +0200
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> skribis:

> For future reference, the bisect output is:
>
>   # first bad commit: [5cf4b26d52bcea382d98fb4becce89be9ee37b55] derivations: <derivation-input> now aggregates a <derivation>.

Does the patch below have any effect?

My understanding is that it shouldn’t have any effect (because inputs
have already been coalesced at that point), but that’s one place where
5cf4b26d52bcea382d98fb4becce89be9ee37b55 introduced a difference.

Thanks in advance,
Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/guix/derivations.scm b/guix/derivations.scm
index 92d50503ce..eb94fea55e 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -239,12 +239,17 @@ the store."
   "Return a list of inputs, such that when INPUTS contains the same DRV twice,
 they are coalesced, with their sub-derivations merged.  This is needed because
 Nix itself keeps only one of them."
+  (define (derivation-file-name* obj)
+    (if (derivation? obj)
+        (derivation-file-name obj)
+        obj))
+
   (fold (lambda (input result)
           (match input
-            (($ <derivation-input> (= derivation-file-name path) sub-drvs)
+            (($ <derivation-input> (= derivation-file-name* path) sub-drvs)
              ;; XXX: quadratic
              (match (find (match-lambda
-                            (($ <derivation-input> (= derivation-file-name p)
+                            (($ <derivation-input> (= derivation-file-name* p)
                                                    s)
                              (string=? p path)))
                           result)
@@ -685,7 +690,7 @@ name of each input with that input's hash."
                              (make-derivation-input hash sub-drvs))))
                         inputs)))
        (make-derivation outputs
-                        (sort inputs
+                        (sort (coalesce-duplicate-inputs inputs)
                               (lambda (drv1 drv2)
                                 (string<? (derivation-input-derivation drv1)
                                           (derivation-input-derivation drv2))))

Severity set to 'important' from 'normal' Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 27 Jul 2019 21:50:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-guix <at> gnu.org:
bug#36777; Package guix. (Tue, 30 Jul 2019 18:37:02 GMT) Full text and rfc822 format available.

Message #22 received at 36777 <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <contact <at> carldong.me>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: "36777\\@debbugs.gnu.org" <36777 <at> debbugs.gnu.org>
Subject: Re: bug#36777: Guix Inferiors: Curious incorrect derivation output bug
Date: Tue, 30 Jul 2019 18:36:01 +0000
All,

Yes! The patch actually fixed the problem when applied on top of 5cf4b26d52bcea382d98fb4becce89be9ee37b55! I was also able to come up with a minimal reproducing manifest:

```
(use-modules (guix inferior) (guix channels)
             (srfi srfi-1))   ;for 'first'

(define channels
  (list (channel
         (name 'guix)
         (url "https://git.savannah.gnu.org/git/guix.git")
         (commit
          "6869b6635afd93872b8f0d9f2db0db4c0d765a86"))))

(define inferior
  ;; An inferior representing the above revision.
  (inferior-for-channels channels))

(packages->manifest
  (map (lambda (x)
         (first (lookup-inferior-packages inferior x)))
       '("gzip")))
```

It seems that the `gzip` package is what's causing this.

Not sure what the next steps are for this, but I'd very much like to understand where this went wrong. Perhaps we could write tests for this so it doesn't happen in the future for releases.

Cheers,
Carl Dong
contact <at> carldong.me
"I fight for the users"




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Fri, 16 Aug 2019 21:04:03 GMT) Full text and rfc822 format available.

Notification sent to Carl Dong <contact <at> carldong.me>:
bug acknowledged by developer. (Fri, 16 Aug 2019 21:04:04 GMT) Full text and rfc822 format available.

Message #27 received at 36777-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: "36777 <at> debbugs.gnu.org" <36777-done <at> debbugs.gnu.org>
Subject: Re: bug#36777: Guix Inferiors: Curious incorrect derivation output bug
Date: Fri, 16 Aug 2019 23:03:23 +0200
Hi Carl,

Carl Dong <contact <at> carldong.me> skribis:

> Yes! The patch actually fixed the problem when applied on top of 5cf4b26d52bcea382d98fb4becce89be9ee37b55!

[...]

> Not sure what the next steps are for this, but I'd very much like to understand where this went wrong. Perhaps we could write tests for this so it doesn't happen in the future for releases.

Yup, I understood when this could happen (if multiple inputs of a
derivation are “fixed-output” derivations leading to the same output),
wrote a test for that, and came up with a simpler fix in commit
268896444bed7b958add74b2e1e86ff802c5f5cb.

Let me know if anything is amiss!

Thanks for testing the patch,
Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 14 Sep 2019 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 241 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.