From 75ede65e3d2527cd9087c5a6970c4c5e6e26a0a8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 4 Mar 2015 15:08:53 +0100 Subject: [PATCH] Don't use vfork() before clone() I'm seeing hangs in Glibc's setxid_mark_thread() again. This is probably because the use of an intermediate process to make clone() safe from a multi-threaded program (see 524f89f1399724e596f61faba2c6861b1bb7b9c5) is defeated by the use of vfork(), since the intermediate process will have a copy of Glibc's threading data structures due to the vfork(). So use a regular fork() again. --- src/libstore/build.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 506eb633a..d02999148 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1992,6 +1992,8 @@ void DerivationGoal::startBuilder() CLONE_PARENT to ensure that the real builder is parented to us. */ + ProcessOptions options; + options.allowVfork = false; Pid helper = startProcess([&]() { char stack[32 * 1024]; int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_PARENT | SIGCHLD; @@ -2004,7 +2006,7 @@ void DerivationGoal::startBuilder() if (child == -1) throw SysError("cloning builder process"); writeFull(builderOut.writeSide, int2String(child) + "\n"); _exit(0); - }); + }, options); if (helper.wait(true) != 0) throw Error("unable to start build process"); pid_t tmp;