mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
libstore: Fix dangling pointers in DerivationGoal constructors
This leads to a use-after free, because staticOutputHashes returns a temporary object that dies before we can do a `return *mOutputHash`. This is most likely the cause for random failures in Hydra [1]. [1]: https://hydra.nixos.org/build/305091330/nixlog/2
This commit is contained in:
parent
4e776a5be8
commit
cea85e79ee
1 changed files with 3 additions and 4 deletions
|
|
@ -34,11 +34,10 @@ DerivationGoal::DerivationGoal(
|
|||
, drvPath(drvPath)
|
||||
, wantedOutput(wantedOutput)
|
||||
, outputHash{[&] {
|
||||
if (auto * mOutputHash = get(staticOutputHashes(worker.evalStore, drv), wantedOutput))
|
||||
auto outputHashes = staticOutputHashes(worker.evalStore, drv);
|
||||
if (auto * mOutputHash = get(outputHashes, wantedOutput))
|
||||
return *mOutputHash;
|
||||
else
|
||||
throw Error(
|
||||
"derivation '%s' does not have output '%s'", worker.store.printStorePath(drvPath), wantedOutput);
|
||||
throw Error("derivation '%s' does not have output '%s'", worker.store.printStorePath(drvPath), wantedOutput);
|
||||
}()}
|
||||
, buildMode(buildMode)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue