public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* main thread pthread_exit/sys_exit bug!
@ 2009-02-01 22:32 Kaz Kylheku
       [not found] ` <20090201174159.4a52e15c.akpm@linux-foundation.org>
  0 siblings, 1 reply; 20+ messages in thread
From: Kaz Kylheku @ 2009-02-01 22:32 UTC (permalink / raw)
  To: linux-kernel

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.

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2009-02-09  5:17 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-01 22:32 main thread pthread_exit/sys_exit bug! Kaz Kylheku
     [not found] ` <20090201174159.4a52e15c.akpm@linux-foundation.org>
2009-02-02  6:45   ` Oleg Nesterov
2009-02-02  7:10     ` Kaz Kylheku
2009-02-02 16:56       ` Oleg Nesterov
2009-02-02 20:10         ` Kaz Kylheku
2009-02-02 20:17         ` Ulrich Drepper
2009-02-02 20:39           ` Kaz Kylheku
2009-02-03  2:39             ` Kaz Kylheku
2009-02-03 13:33               ` Oleg Nesterov
2009-02-03 19:51                 ` Kaz Kylheku
2009-02-03 21:32                   ` Oleg Nesterov
2009-02-03 23:06                     ` Kaz Kylheku
2009-02-05  3:05         ` Roland McGrath
2009-02-05  4:55           ` Kaz Kylheku
2009-02-05 16:15             ` Oleg Nesterov
2009-02-05 21:22               ` Roland McGrath
2009-02-05 23:22                 ` Oleg Nesterov
2009-02-09  3:33                   ` Roland McGrath
2009-02-09  4:52                     ` Oleg Nesterov
2009-02-09  5:14                       ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox