Title: _lsprof (cProfile): Profiler.clear() keeps references to detroyed nodes
Type: crash Stage:
Components: Extension Modules Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alexandre.vassalotti, haypo
Priority: normal Keywords: patch

Created on 2009-12-13 19:05 by haypo, last changed 2010-03-21 13:39 by haypo. This issue is now closed.

File name Uploaded Description Edit
_lsprof.patch haypo, 2009-12-13 19:05
Messages (5)
msg96346 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2009-12-13 19:05
clearEntries() delete all nodes of the profiler tree, but 
currentProfilerContext keeps a reference to a tree node 
(currentProfilerContext->previous->header attribute).

The patch fixes clearEntries() to delete all references (destroy 
currentProfilerContext and set it to NULL).
msg96347 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2009-12-13 19:11
The crash is an Heisenbug (read object which just has been destroyed, 
sometimes it works, sometimes it crash), so it's not easy the write a 
short example showing the crash.

The code looks like:

   import cProfile
   prof = cProfile.Profile()

The next instruction will be analyzed by the profiler, but the profiler 
will crash in: ptrace_enter_call()->initContext()->getSubEntry()-
>Rotating_Tree_Get(&caller->calls, entry), because caller->calls node is 
msg96348 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2009-12-13 19:15
See also issue #3952.
msg100361 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2010-03-04 00:34
Sorry, but I'm unable to write a reliable unit test. You have to trust me: the patch fixes the issue and the issue does exist :-)

Fixed by r78641 (trunk), r78642 (py3k), r78643 (3.1).

Leave this issue open until the fix can be backported to 2.6 (after 2.6.5 release).
msg101423 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2010-03-21 13:39
> Fixed by r78641 (trunk)

Backport done: r79200 (2.6).
Date User Action Args
2010-03-21 13:39:04hayposetstatus: open -> closed
resolution: fixed
messages: + msg101423
2010-03-04 00:34:31hayposetmessages: + msg100361
2010-01-13 08:18:39pitrousetnosy: + alexandre.vassalotti
2009-12-13 19:15:39hayposetmessages: + msg96348
2009-12-13 19:11:30hayposetmessages: + msg96347
2009-12-13 19:05:40haypocreate