[ python-Bugs-744841 ] Python-Profiler bug: Bad call

SourceForge.net noreply at sourceforge.net
Fri Jan 16 11:33:53 EST 2004

Bugs item #744841, was opened at 2003-05-28 11:02
Message generated for change (Comment added) made by glyf
You can respond by visiting: 

Category: Python Interpreter Core
Group: Python 2.1.2
Status: Closed
Resolution: Out of Date
Priority: 5
Submitted By: Dieter Maurer (dmaurer)
Assigned to: Nobody/Anonymous (nobody)
Summary: Python-Profiler bug: Bad call

Initial Comment:
There is a timing problem between the call of 
"call_trace(profile_func,...,'return',...)" and 
"reset_exc_info" in Pythons main interpreter loop.

The main loop first calls "call_trace" (at the end of
function execution). With the
standard "profile.Profile" profiler this leads to a pop
of the current frame from the profiler stack while
the current frame is still on the interpreter stack.
Then "reset_exc_info" is called. When this call releases 
an instance with a destructor ("__del__" method), the 
"call_trace(profile_func,...'call',...)" for the destructor 
observes the inconsistency between the profiler and the 
interpreter stack and raises a "Bad call" exception. This 
exception disables profiling effectively. However, the 
exception is later ignored (as we are in a destructor) and 
program execution continues. When the profiling is later 
finished, all time after the exception is accounted for the 
last function, that was on top of the profiler stack when 
profiling was disabled. This can be extremely confusing.

The attached script reproduces the problem. Run it 
through the Python interpreter. When you see an 
"Exception Bad call ... ignored", the interpreter has the 
described problem. We observed the problem in Python 
(on Linux, Solaris and Windows).


Comment By: Glyph Lefkowitz (glyf)
Date: 2004-01-16 16:33

Logged In: YES 

I believe this bug has cropped up again.  On my Debian system:

glyph at kazekage:~% python -V ; python Downloads/prof2.py |
head -3
Python 2.3.3
Exception exceptions.AssertionError:
<exceptions.AssertionError instance at 0x403b270c> in <bound
method C.__del__ of <__main__.C instance at 0x403b26ec>> ignored
         5 function calls in 0.000 CPU seconds

This is not the same error as before, but it is just as
clearly wrong.


Comment By: Raymond Hettinger (rhettinger)
Date: 2003-06-25 15:27

Logged In: YES 

I've run your script on Py2.2.3 and 2.3b1+ and did not 
observe "Exception Bad cad ... ignored".

Marking this one as already fixed.


Comment By: Dieter Maurer (dmaurer)
Date: 2003-06-06 08:23

Logged In: YES 

Apparently, a colleague observed the bug also in Python 2.2.2.


Comment By: Neal Norwitz (nnorwitz)
Date: 2003-05-29 00:01

Logged In: YES 

The good news is that this has been fixed in Python 2.2.x
and beyond.


You can respond by visiting: 

More information about the Python-bugs-list mailing list