Author Ringding
Recipients Ringding
Date 2013-01-31.21:39:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1359668363.58.0.777154629349.issue17094@psf.upfronthosting.co.za>
In-reply-to
Content
After a fork, the list of thread states contains all the threads from before. It is especially unfortunate that, at least for me, it usually happens that threads created in the forked process reuse the same thread ids, and sys._current_frames will then return wrong stack frames for existing threads because the old entries occur towards the tail of the linked list and overwrite the earlier, correct ones, in _PyThread_CurrentFrames.

The attached patch is certainly not the most complete solution, but it solves my problem.

With Python 2.7.3 I get:

Exception in thread Thread-6:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "test-fork-frames.py", line 24, in do_verify
    assert frame_from_sys is real_frame
AssertionError

With my patch applied, it passes silently. I can reproduce this on CentOS 6.3 x86_64 as well as Fedora 18 x86_64.
History
Date User Action Args
2013-01-31 21:39:23Ringdingsetrecipients: + Ringding
2013-01-31 21:39:23Ringdingsetmessageid: <1359668363.58.0.777154629349.issue17094@psf.upfronthosting.co.za>
2013-01-31 21:39:23Ringdinglinkissue17094 messages
2013-01-31 21:39:23Ringdingcreate