using ^output selection syntax on store paths outputs crashes the daemon #312

Closed
opened 2024-05-13 06:05:01 +00:00 by qyriad · 4 comments
Owner
$ nix build '/nix/store/dr53sp25hyfsnzjpm8mh3r3y36vrw3ng-neovim-0.9.5^out'
error: Nix daemon disconnected unexpectedly (maybe it crashed?)

And in the journal we get:

nix-daemon: src/libstore/derivations.cc:931: static std::string_view nix::BasicDerivation::nameFromPath(const nix::StorePath&): Assertion `nameWithSuffix.ends_with(extension)' failed.

which thankfully seems to point to a pretty clear place

reproduced on 2.90.0-lixpre20240512-4b35e6a. credit to julia on matrix for finding this

```bash $ nix build '/nix/store/dr53sp25hyfsnzjpm8mh3r3y36vrw3ng-neovim-0.9.5^out' error: Nix daemon disconnected unexpectedly (maybe it crashed?) ``` And in the journal we get: ``` nix-daemon: src/libstore/derivations.cc:931: static std::string_view nix::BasicDerivation::nameFromPath(const nix::StorePath&): Assertion `nameWithSuffix.ends_with(extension)' failed. ``` which thankfully seems to point to a pretty clear place reproduced on 2.90.0-lixpre20240512-4b35e6a. credit to julia on matrix for finding this
qyriad added the
stability
bug
Area/store
labels 2024-05-13 06:05:01 +00:00
Author
Owner

Reproduced on Nix 2.18. Did not reproduce on Nix 2.3.

Reproduced on Nix 2.18. Did not reproduce on Nix 2.3.
qyriad added the
E/easy
label 2024-05-13 06:50:56 +00:00
Member

I looked a bit into this and I feel like I now understand pretty well the issue. Essentially, the ^out syntax can only work on a derivation, since there is no way to go from an opaque store path for an output to another output. The build worker code already only handles that case (built derived paths always trigger a DerivationGoal, unlike opaque derived paths which trigger a SubstitutionGoal) and I don't think it can realistically handle other cases.

So IMO the correct fix here is to fail at parsing time and require that the base path of a built derived path can only be a .drv (StorePath::isDerivation). I couldn't find any documentation for this feature in Nix so I'm kind of guessing at everything here. Your input would be extremely valued :-)

If that fix is ok with you I'll look into 1. implementing it; 2. adding some unit tests.

(I, uh, kind of dispute that "Easy" label on the issue given that I spent 2h30 looking into this :P)

I looked a bit into this and I feel like I now understand pretty well the issue. Essentially, the ^out syntax can only work on a derivation, since there is no way to go from an opaque store path for an output to another output. The build worker code already only handles that case (built derived paths always trigger a DerivationGoal, unlike opaque derived paths which trigger a SubstitutionGoal) and I don't think it *can* realistically handle other cases. So IMO the correct fix here is to fail at parsing time and require that the base path of a built derived path can only be a .drv (StorePath::isDerivation). I couldn't find *any* documentation for this feature in Nix so I'm kind of guessing at everything here. Your input would be extremely valued :-) If that fix is ok with you I'll look into 1. implementing it; 2. adding some unit tests. (I, uh, kind of dispute that "Easy" label on the issue given that I spent 2h30 looking into this :P)
delroth self-assigned this 2024-05-16 22:19:21 +00:00
qyriad removed the
E/easy
label 2024-05-16 22:50:40 +00:00
Author
Owner

Failing at parse time is definitely the way to go, imo, unless you can think of anything better. Re: documentation, if you're referring to the ^ syntax, it is actually documented, albeit in one of the (relatively…) more useful pages in the manual that's basically linked nowhere: https://docs.lix.systems/manual/nightly/command-ref/new-cli/nix.html#derivation-output-selection

Failing at parse time is definitely the way to go, imo, unless you can think of anything better. Re: documentation, if you're referring to the `^` syntax, it *is* actually documented, albeit in one of the (relatively…) more useful pages in the manual that's basically linked nowhere: https://docs.lix.systems/manual/nightly/command-ref/new-cli/nix.html#derivation-output-selection
Member
https://gerrit.lix.systems/c/lix/+/1151
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#312
No description provided.