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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user