New submission from Stefan Ring:

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.

----------
components: Interpreter Core
files: current-frames-cleanup.patch
keywords: patch
messages: 181045
nosy: Ringding
priority: normal
severity: normal
status: open
title: sys._current_frames() reports too many/wrong stack frames
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file28924/current-frames-cleanup.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17094>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to