aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-10-07 16:34:03 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-10-07 16:34:03 +0200
commitbe149acfdaae06667bc58df467c04c41827b69d0 (patch)
tree29bd64b3867cf616387d92cb5332eac1737d6ab4 /src/libstore/build.cc
parent27ca87c46a57e1e6603028c1902189b53635d576 (diff)
Serialize exceptions from the sandbox process to the parent
Fixes #4118.
Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 9497e7b3e..fa7283588 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2737,9 +2737,12 @@ void DerivationGoal::startBuilder()
/* Check if setting up the build environment failed. */
while (true) {
string msg = readLine(builderOut.readSide.get());
+ if (string(msg, 0, 1) == "\2") break;
if (string(msg, 0, 1) == "\1") {
- if (msg.size() == 1) break;
- throw Error(string(msg, 1));
+ FdSource source(builderOut.readSide.get());
+ auto ex = readError(source);
+ ex.addTrace({}, "while setting up the build environment");
+ throw ex;
}
debug(msg);
}
@@ -3785,7 +3788,7 @@ void DerivationGoal::runChild()
args.push_back(rewriteStrings(i, inputRewrites));
/* Indicate that we managed to set up the build environment. */
- writeFull(STDERR_FILENO, string("\1\n"));
+ writeFull(STDERR_FILENO, string("\2\n"));
/* Execute the program. This should not return. */
if (drv->isBuiltin()) {
@@ -3815,8 +3818,11 @@ void DerivationGoal::runChild()
throw SysError("executing '%1%'", drv->builder);
- } catch (std::exception & e) {
- writeFull(STDERR_FILENO, "\1while setting up the build environment: " + string(e.what()) + "\n");
+ } catch (Error & e) {
+ writeFull(STDERR_FILENO, "\1\n");
+ FdSink sink(STDERR_FILENO);
+ sink << e;
+ sink.flush();
_exit(1);
}
}