main thread pthread_exit/sys_exit bug!
From: Kaz Kylheku
Date: Sun Feb 01 2009 - 17:32:35 EST
Basically, if you call pthread_exit from the main thread of a process, and keep
other threads running, the behavior is ugly.
I logged this initially as a bug against glibc, but then resolved it
with a kernel patch against linux 2.6.26:
Please see:
http://sources.redhat.com/bugzilla/show_bug.cgi?id=9804
I've known about this for some time, first having reproduced it on 2.6.17;
finally got around to fixing it.
When the main thread of a POSIX threads process calls pthread_exit, the process
should stick around until all the other threads do the same, or until one of
them calls _exit or exit, or until the process terminates abnormally. During
this time, it would be nice if the process behaved normally: if it did not
appear defunct in the process list and if POSIX job control was possible on it.
An easy way to achieve this is to insert a wait into the top of sys_exit, so
that do_exit is not called unless all the other threads have terminated. This
is another special case like do_group_exit. In the group exit, we zap the other
threads. In this case, we must not zap the other threads, but neither should we
fall through do_exit and become defunct!
The patch involves a controversial move: returning -ERESTARTSYS from sys_exit.
This is because the main thread may be stuck in sys_exit and have to respond to
a signal, and then go back to sys_exit. It appears to be working fine.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/