[issue1856] shutdown (exit) can hang or segfault with daemon threads running

Adam Olsen report at bugs.python.org
Wed May 7 20:11:55 CEST 2008


Adam Olsen <rhamph at gmail.com> added the comment:

Cleaned up version of Amaury's patch.  I stop releasing the GIL after
sys.exitfunc is called, which protects threads from the ensuing teardown.

I also grab the import lock (and never release it).  This should prevent
the nasty issue with daemon threads doing imports mentioned in issue
1720705, so that part of the documentation change can be removed.  I
didn't do any significant testing though.

Importing raises a potential issue with this approach.  The standard
meme of "release GIL; grab lock; acquire GIL" becomes invalid.  A child
may grab the lock, then block on the GIL, while the main thread (which
never releases the GIL) will block on acquiring the lock.  I worked
around it with the import lock due to it's recursive behaviour, but if
it exists anywhere else in CPython it may cause a problem if used during
shutdown.

----------
keywords: +patch
Added file: http://bugs.python.org/file10208/python-thread_noswap-2.diff

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1856>
__________________________________


More information about the Python-bugs-list mailing list