lix/src/libstore
jade c897fba787 store: fix null reference from DerivationGoal::waiteeDone
This happened during a PathSubstitutionGoal of a .drv file:

substitution of '/tmp/jade/nix-test/ca/eval-store/store/1lj7lsq5y0f25mfbnq6d3zd0bw5ay33n-dependencies-input-2.drv'

What happened here is that since PathSubstitutionGoal is not a
DerivationGoal, in production builds, the UB was not caught, since it
would early-exit from failing a dynamic_cast to DerivationGoal * on the
very next line, but before the null reference was ever used.

This was nonetheless UB. The fix should be to just rearrange the two
lines; I don't think there is a further bug there, since *substituting a
.drv* **necessarily** means you cannot have the representation of
the derivation as would be necessary for drv to not be null there.

Test failure:

++(eval-store.sh:12) _RR_TRACE_DIR=/home/jade/.local/share/rr rr record -- nix build -f dependencies.nix --eval-store /tmp/jade/nix-test/ca/eval-store/eval-store -o /tmp/jade/nix-test/ca/eval-store/result
don't know how to build these paths:
  /tmp/jade/nix-test/ca/eval-store/store/6y51mf0p57ggipgab6hdjabbvplzsicq-dependencies-top.drv
copying 1 paths...
copying path '/tmp/jade/nix-test/ca/eval-store/store/8027afyvqb87y1sf5xhdkqsflqn1ziy8-dependencies.builder0.sh' to 'local'...
copying 1 paths...
copying path '/tmp/jade/nix-test/ca/eval-store/store/7r5pqyncvfgrryf9gzy1z56z3xigi61x-builder-dependencies-input-0.sh' to 'local'...
copying 1 paths...
copying path '/tmp/jade/nix-test/ca/eval-store/store/nhmgm87zlqy3ks96dxrn7l37b72azi99-builder-dependencies-input-1.sh' to 'local'...
copying 1 paths...
copying path '/tmp/jade/nix-test/ca/eval-store/store/nq4qa2j6y8ajqazlfq6h46ck637my1n6-builder-dependencies-input-2.sh' to 'local'...
copying 1 paths...
copying path '/tmp/jade/nix-test/ca/eval-store/store/6vh0vna9l5afck01y7iaks3hm9ikwqyj-builder-fod-input.sh' to 'local'...
building '/tmp/jade/nix-test/ca/eval-store/store/gy91pqymf2nc5v7ld1bad94xpwxdi25s-dependencies-input-0.drv'...
building '/tmp/jade/nix-test/ca/eval-store/store/w7wlkjx97ivmnrymkac5av3nyp94hzvq-dependencies-input-1.drv'...
../src/libstore/build/derivation-goal.cc:1556:22: runtime error: reference binding to null pointer of type 'Derivation'
    0 0x734ba59a6886 in nix::DerivationGoal::waiteeDone(std::shared_ptr<nix::Goal>, nix::Goal::ExitCode) /home/jade/lix/lix2/build/src/libstore/build/derivation-goal.cc:1556:12
    1 0x734ba59c0962 in nix::Goal::amDone(nix::Goal::ExitCode, std::optional<nix::Error>) /home/jade/lix/lix2/build/src/libstore/build/goal.cc:95:25
    2 0x734ba5a1c44a in nix::PathSubstitutionGoal::done(nix::Goal::ExitCode, nix::BuildResult::Status, std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>) /home/jade/lix/lix2/build/src/libstore/build/substitution-goal.cc:38:5
    3 0x734ba5a1b454 in nix::PathSubstitutionGoal::init() /home/jade/lix/lix2/build/src/libstore/build/substitution-goal.cc:56:9
    4 0x734ba5a2a6c6 in nix::Worker::run(std::set<std::shared_ptr<nix::Goal>, nix::CompareGoalPtrs, std::allocator<std::shared_ptr<nix::Goal>>> const&) /home/jade/lix/lix2/build/src/libstore/build/worker.cc:320:23
    5 0x734ba59b93d8 in nix::Store::buildPathsWithResults(std::vector<nix::DerivedPath, std::allocator<nix::DerivedPath>> const&, nix::BuildMode, std::shared_ptr<nix::Store>) /home/jade/lix/lix2/build/src/libstore/build/entry-points.cc:60:12
    6 0x734ba663c107 in nix::Installable::build2(nix::ref<nix::Store>, nix::ref<nix::Store>, nix::Realise, std::vector<nix::ref<nix::Installable>, std::allocator<nix::ref<nix::Installable>>> const&, nix::BuildMode) /home/jade/lix/lix2/build/src/libcmd/installables.cc:637:36

Change-Id: Id0e651e480bebf6356733b01bc639e9bb59c7bd0
2024-06-18 19:26:54 -07:00
..
build store: fix null reference from DerivationGoal::waiteeDone 2024-06-18 19:26:54 -07:00
builtins filetransfer: remove decompress request parameter 2024-04-25 01:33:08 +02:00
linux chore: rebrand Nix to Lix when it makes sense 2024-06-01 20:31:24 +02:00
platform gc: Find roots using libproc on Darwin 2024-04-25 23:24:21 -04:00
binary-cache-store.cc Change error messages about 'invalid paths' to 'path does not exist'. 2024-06-16 03:55:39 +00:00
binary-cache-store.hh libstore: un-callback-ify Store::queryRealisationUncached 2024-05-09 23:18:05 +02:00
build-result.cc Merge pull request #9094 from obsidiansystems/test-proto 2024-03-04 04:36:23 +01:00
build-result.hh Merge pull request #9094 from obsidiansystems/test-proto 2024-03-04 04:36:23 +01:00
builtins.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
ca-specific-schema.sql ca: add sqlite index on RealisationsRefs(realisationReference) 2022-04-21 10:06:39 +02:00
common-protocol-impl.hh Merge pull request #9099 from obsidiansystems/common-proto 2024-03-04 04:36:58 +01:00
common-protocol.cc util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
common-protocol.hh Merge pull request #9099 from obsidiansystems/common-proto 2024-03-04 04:36:58 +01:00
content-address.cc Fix various clang-tidy lints 2024-03-29 20:26:38 -07:00
content-address.hh Fix various clang-tidy lints 2024-03-29 20:26:38 -07:00
crypto.cc util.{hh,cc}: Split out strings.{hh,cc} 2024-05-29 11:01:34 +02:00
crypto.hh util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
daemon.cc libstore: refuse to serialise ancient protocols 2024-06-16 19:15:08 -07:00
daemon.hh Add Store::isTrustedClient() 2023-04-06 19:59:57 -04:00
derivations.cc util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
derivations.hh doc: rewrite the multi-user documentation to actually talk about security 2024-06-12 15:34:23 -07:00
derived-path-map.cc Revert "Adapt scheduler to work with dynamic derivations" 2023-10-02 15:05:23 +00:00
derived-path-map.hh pragma once and ///@file everything missing it 2024-04-08 15:40:12 -07:00
derived-path.cc derived-path: refuse built derived path with a non-derivation base 2024-05-17 02:16:15 +02:00
derived-path.hh util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
downstream-placeholder.cc Introduce OutputName and OutputNameView type aliases 2023-08-25 09:55:07 -04:00
downstream-placeholder.hh Introduce OutputName and OutputNameView type aliases 2023-08-25 09:55:07 -04:00
dummy-store.cc libutil: remove callback.hh 2024-05-10 02:21:11 +02:00
dummy-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
export-import.cc libstore: un-inline copyNAR expansions 2024-03-24 15:24:02 +01:00
filetransfer.cc filetransfer: {up,down}load -> transfer 2024-06-18 23:58:25 +00:00
filetransfer.hh filetransfer: {up,down}load -> transfer 2024-06-18 23:58:25 +00:00
fs-accessor.hh Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
gc-store.hh libstore: Create platform LocalStore subclasses 2024-04-23 16:17:05 +00:00
gc.cc util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
globals.cc chore: rebrand Nix to Lix when it makes sense 2024-06-01 20:31:24 +02:00
globals.hh doc: rewrite the multi-user documentation to actually talk about security 2024-06-12 15:34:23 -07:00
http-binary-cache-store.cc filetransfer: {up,down}load -> transfer 2024-06-18 23:58:25 +00:00
http-binary-cache-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
indirect-root-store.hh Clean up store hierarchy with IndirectRootStore 2023-07-24 09:19:44 -04:00
legacy-ssh-store.cc libutil: remove callback.hh 2024-05-10 02:21:11 +02:00
legacy-ssh-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
length-prefixed-protocol-helper.hh Merge pull request #9099 from obsidiansystems/common-proto 2024-03-04 04:36:58 +01:00
lix-store.pc.in packaging: rename nixexpr -> lixexpr and so on 2024-05-23 16:45:23 -06:00
local-binary-cache-store.cc Delete hasPrefix and hasSuffix from the codebase 2024-03-17 20:17:19 -07:00
local-binary-cache-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
local-fs-store.cc Change error messages about 'invalid paths' to 'path does not exist'. 2024-06-16 03:55:39 +00:00
local-fs-store.hh chore: rebrand Nix to Lix when it makes sense 2024-06-01 20:31:24 +02:00
local-store.cc Change the sqlite missing valid path message to say it's the db 2024-06-15 22:31:23 -07:00
local-store.hh chore: rebrand Nix to Lix when it makes sense 2024-06-01 20:31:24 +02:00
local-store.md Tweaks 2023-03-23 15:32:59 +01:00
lock.cc util.{hh,cc}: Split out file-descriptor.{hh,cc} 2024-05-29 09:54:47 +02:00
lock.hh Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
log-store.cc Move the getBuildLog implementation to its own implementation file 2023-01-13 11:05:44 +01:00
log-store.hh Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
machines.cc Remove 100s of CPU time (10%) from build times (1465s -> 1302s) 2024-05-29 22:16:15 -07:00
machines.hh Merge pull request #9841 from obsidiansystems/float-speed-factor 2024-03-04 08:40:38 +01:00
make-content-addressed.cc Merge pull request #8650 from obsidiansystems/content-address-simpler 2023-07-21 13:46:53 +02:00
make-content-addressed.hh makeContentAddressed: Add single path helper 2023-06-30 18:22:47 +02:00
meson.build build: expose option to enable or disable precompiled std headers 2024-06-06 12:46:26 -06:00
misc.cc libutil: remove callback.hh 2024-05-10 02:21:11 +02:00
names.cc util.{hh,cc}: Split out strings.{hh,cc} 2024-05-29 11:01:34 +02:00
names.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
nar-accessor.cc Add explicit case statements where -Wswitch-enum would report them 2023-04-03 18:17:32 +02:00
nar-accessor.hh Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
nar-info-disk-cache.cc util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
nar-info-disk-cache.hh Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
nar-info.cc Make "NAR info file is corrupt" messages more informative 2023-04-18 14:10:49 +02:00
nar-info.hh Merge remote-tracking branch 'upstream/master' into path-info 2023-04-07 20:39:04 -04:00
optimise-store.cc util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
outputs-spec.cc util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
outputs-spec.hh Introduce OutputName and OutputNameView type aliases 2023-08-25 09:55:07 -04:00
parsed-derivations.cc Fix exportReferencesGraph when given store subpath 2024-04-21 10:27:32 +00:00
parsed-derivations.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
path-info.cc Merge pull request #6223 from obsidiansystems/worker-proto-with-version 2024-03-04 04:59:31 +01:00
path-info.hh Merge pull request #9238 from tfc/small-improvements2 2024-03-04 05:18:05 +01:00
path-references.cc util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
path-references.hh pragma once and ///@file everything missing it 2024-04-08 15:40:12 -07:00
path-regex.hh Disallow store path names that are . or .. (plus opt. -) 2024-05-02 19:34:38 +02:00
path-with-outputs.cc Fixing #7479 2023-08-18 11:44:00 -04:00
path-with-outputs.hh Make the Derived Path family of types inductive for dynamic derivations 2023-08-10 00:08:32 -04:00
path.cc Disallow store path names that are . or .. (plus opt. -) 2024-05-02 19:34:38 +02:00
path.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
pathlocks.cc util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
pathlocks.hh util.{hh,cc}: Split out file-descriptor.{hh,cc} 2024-05-29 09:54:47 +02:00
platform.cc gc: Find roots using libproc on Darwin 2024-04-25 23:24:21 -04:00
profiles.cc util.{hh,cc}: Split out users.{hh,cc} 2024-05-29 11:01:34 +02:00
profiles.hh chore: rebrand Nix to Lix when it makes sense 2024-06-01 20:31:24 +02:00
realisation.cc libutil: de-callback-ify computeClosure 2024-05-07 14:35:20 +00:00
realisation.hh Introduce OutputName and OutputNameView type aliases 2023-08-25 09:55:07 -04:00
remote-fs-accessor.cc Change error messages about 'invalid paths' to 'path does not exist'. 2024-06-16 03:55:39 +00:00
remote-fs-accessor.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
remote-store-connection.hh libstore: refuse to serialise ancient protocols 2024-06-16 19:15:08 -07:00
remote-store.cc libstore client: remove remaining dead code 2024-06-16 19:15:08 -07:00
remote-store.hh libstore: un-callback-ify Store::queryRealisationUncached 2024-05-09 23:18:05 +02:00
s3-binary-cache-store.cc libstore: work around aws sdk log spam at debug level 2024-06-18 15:11:49 -07:00
s3-binary-cache-store.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
s3-binary-cache-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
s3.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
schema.sql schema.sql: add comment about hash being in base16 2022-06-01 14:59:57 +02:00
serve-protocol-impl.hh Merge pull request #9137 from obsidiansystems/serve-protocol 2024-03-04 04:37:05 +01:00
serve-protocol.cc util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
serve-protocol.hh Merge pull request #9560 from obsidiansystems/serve-proto-unkeyed-valid-path-info-serializer 2024-03-07 12:37:33 +01:00
sqlite.cc util.hh: Delete remaining file and clean up headers 2024-05-29 12:38:51 +02:00
sqlite.hh Merge pull request #9925 from 9999years/fmt-cleanup 2024-03-09 07:00:13 -07:00
ssh-store-config.hh Merge pull request #6258 from obsidiansystems/gcc-bug-ergonomics 2024-03-04 05:24:33 +01:00
ssh-store.cc ssh-ng: Set log-fd for ssh to 4 by default 2024-04-26 19:04:06 +02:00
ssh-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
ssh.cc util.{hh,cc}: Split out strings.{hh,cc} 2024-05-29 11:01:34 +02:00
ssh.hh util.{hh,cc}: Split out processes.{hh,cc} 2024-05-29 11:01:34 +02:00
store-api.cc store-api: fix/clarify capture lifetimes in copyPaths 2024-06-18 15:11:49 -07:00
store-api.hh Add a clearer error message for InvalidPathError during evaluation 2024-06-16 03:53:00 +00:00
store-cast.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
uds-remote-store.cc util.{hh,cc}: Split out unix-domain-socket.{hh,cc} 2024-05-29 11:01:34 +02:00
uds-remote-store.hh Clean up store hierarchy with IndirectRootStore 2023-07-24 09:19:44 -04:00
uds-remote-store.md Support per-store Markdown documentation 2023-03-21 14:03:40 +01:00
worker-protocol-impl.hh Merge pull request #9099 from obsidiansystems/common-proto 2024-03-04 04:36:58 +01:00
worker-protocol.cc libstore client: remove remaining dead code 2024-06-16 19:15:08 -07:00
worker-protocol.hh libstore: refuse to serialise ancient protocols 2024-06-16 19:15:08 -07:00