On Wed, 09 Dec 2009 19:31:52 +0100, Oleg Nesterov wrote: > Hmm. it is obvioulsy racy, "static volatile unsigned started" > is not atomic and thus the main thread can hang doing > > while (started < THREADS); > > not that I think this explains the failure though.
Thanks, fixed (but the problem is not reproducible for me). Regards, Jan --- ppc-dabr-race.c 8 Dec 2008 18:23:41 -0000 1.8 +++ ppc-dabr-race.c 14 Dec 2009 12:03:49 -0000 1.9 @@ -141,13 +141,14 @@ handler_fail (int signo) assert (0); } +/* STARTED requires atomic access. */ static volatile unsigned started; static void *child_thread (void *data) { pid_t tid = gettid (); - started++; + __sync_add_and_fetch (&started, 1); /* We should stay in the syscall - better race probability. */ sleep (1); @@ -178,7 +179,7 @@ static void child_func (void) assert (i == 0); } - while (started < THREADS); + while (__sync_add_and_fetch (&started, 0) < THREADS); l = ptrace (PTRACE_TRACEME, 0, NULL, NULL); assert (l == 0);