aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/drv-output-substitution-goal.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2023-03-07 13:51:02 +0100
committerEelco Dolstra <edolstra@gmail.com>2023-03-08 11:09:15 +0100
commit7bfed34367f49ea2d4fe52e5861e5969fc9f4b59 (patch)
treec5316dd6b8ae983cafeb1fec342118abf6acb5e1 /src/libstore/build/drv-output-substitution-goal.hh
parentba0486f045d4f7f304bd8c4a939ca2e658affcc8 (diff)
Fix crash/hang with CA derivations
The curl download can outlive DrvOutputSubstitutionGoal (if some other error occurs), so at shutdown setting the promise to an exception will fail because 'this' is no longer valid in the callback. This can manifest itself as a segfault, "corrupted double-linked list" or hang.
Diffstat (limited to 'src/libstore/build/drv-output-substitution-goal.hh')
-rw-r--r--src/libstore/build/drv-output-substitution-goal.hh12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libstore/build/drv-output-substitution-goal.hh b/src/libstore/build/drv-output-substitution-goal.hh
index 948dbda8f..e4b044790 100644
--- a/src/libstore/build/drv-output-substitution-goal.hh
+++ b/src/libstore/build/drv-output-substitution-goal.hh
@@ -16,7 +16,7 @@ class Worker;
// 2. Substitute the corresponding output path
// 3. Register the output info
class DrvOutputSubstitutionGoal : public Goal {
-private:
+
// The drv output we're trying to substitue
DrvOutput id;
@@ -30,9 +30,13 @@ private:
/* The current substituter. */
std::shared_ptr<Store> sub;
- Pipe outPipe;
- std::thread thr;
- std::promise<std::shared_ptr<const Realisation>> promise;
+ struct DownloadState
+ {
+ Pipe outPipe;
+ std::promise<std::shared_ptr<const Realisation>> promise;
+ };
+
+ std::shared_ptr<DownloadState> downloadState;
/* Whether a substituter failed. */
bool substituterFailed = false;