Author emptysquare
Recipients emptysquare
Date 2013-07-09.22:13:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1373408030.66.0.77258289483.issue18418@psf.upfronthosting.co.za>
In-reply-to
Content
In threading.Thread.__bootstrap_inner(), the thread sets self.__started before adding itself to the _active collection. If a different thread forks between these two operations, we're left with a thread that believes it's alive although it isn't. _after_fork() doesn't call __stop() on this thread because the thread isn't in _active.

In the attached patch, Thread adds itself to _active before setting self.__started. This way, if it's interrupted by a fork, it may end up stopped without being started, rather than the reverse. In this case isAlive() correctly returns False.

One concern about the patch: my new test in test_threading.py only reveals the bug in Python 2.7.5 very occasionally. I don't know how to force the test to fail more frequently.

Looking at the threading.py on the 3.3 branch, it appears to have the same bug, but I can't reproduce it there, only on the 2.7 branch.
History
Date User Action Args
2013-07-09 22:13:50emptysquaresetrecipients: + emptysquare
2013-07-09 22:13:50emptysquaresetmessageid: <1373408030.66.0.77258289483.issue18418@psf.upfronthosting.co.za>
2013-07-09 22:13:50emptysquarelinkissue18418 messages
2013-07-09 22:13:50emptysquarecreate