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
524f89f139) 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.
This commit is contained in:
Eelco Dolstra 2015-03-04 15:08:53 +01:00
parent c2699be93b
commit 75ede65e3d

View file

@ -1992,6 +1992,8 @@ void DerivationGoal::startBuilder()
CLONE_PARENT to ensure that the real builder is parented to CLONE_PARENT to ensure that the real builder is parented to
us. us.
*/ */
ProcessOptions options;
options.allowVfork = false;
Pid helper = startProcess([&]() { Pid helper = startProcess([&]() {
char stack[32 * 1024]; char stack[32 * 1024];
int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_PARENT | SIGCHLD; 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"); if (child == -1) throw SysError("cloning builder process");
writeFull(builderOut.writeSide, int2String(child) + "\n"); writeFull(builderOut.writeSide, int2String(child) + "\n");
_exit(0); _exit(0);
}); }, options);
if (helper.wait(true) != 0) if (helper.wait(true) != 0)
throw Error("unable to start build process"); throw Error("unable to start build process");
pid_t tmp; pid_t tmp;