[Python-bugs-list] exception during settrace line event dumps core (PR#73)
jeremy@cnri.reston.va.us
jeremy@cnri.reston.va.us
Tue, 7 Sep 1999 10:17:59 -0400 (EDT)
Full_Name: Jeremy Hylton
Version: 1.5.2 (& current CVS)
OS: Linux & Solaris
Submission from: port1-16.jagunet.com (206.156.212.48)
If a trace function is installed via sys.settrace and the trace function
raises an exception while handling a line event, the interpreter gets stuck
in a loop where it raises line events recursively until it dumps core.
The problem only occurs with class based exceptions. If you run python -X,
you get a traceback as expected.
The problem might by PyErr_NormalizeException, which appears a lot in the stack
trace below.
Here is a simple test program that demonstrates the problem:
import sys
class Tracer:
def trace(self, frame, event, arg):
if event == 'line':
print event
print frame.foo
print "oops"
return self.trace
def test():
x = 1
import test.pystone
t = Tracer()
sys.settrace(t.trace)
test()
#0 __pthread_mutex_unlock (mutex=0x40296858) at queue.h:57
#1 0x402410e0 in __libc_malloc (bytes=27) at malloc.c:2562
#2 0x8075772 in PyString_FromString (str=0x80fb954 "foo")
at stringobject.c:145
#3 0x805bd48 in PyErr_SetString (exception=0x80d7778, string=0x80fb954 "foo")
at errors.c:104
#4 0x8062f38 in PyMember_Get (addr=0x80eacc0 "\006", mlist=0x80b58e4,
name=0x80fb954 "foo") at structmember.c:158
#5 0x806e021 in frame_getattr (f=0x80eacc0, name=0x80fb954 "foo")
at frameobject.c:66
#6 0x8074eaf in PyObject_GetAttrString (v=0x80eacc0, name=0x80fb954 "foo")
at object.c:381
#7 0x8074fcd in PyObject_GetAttr (v=0x80eacc0, name=0x80fb940) at object.c:438
#8 0x8054bde in eval_code2 (co=0x80fb9c8, globals=0x80cefc8, locals=0x0,
args=0x80db6c4, argcount=4, kws=0x0, kwcount=0, defs=0x0, defcount=0,
owner=0x80f0b60) at ceval.c:1382
#9 0x80566a8 in call_function (func=0x80fbaf8, arg=0x80db6b8, kw=0x0)
at ceval.c:2484
#10 0x805628a in PyEval_CallObjectWithKeywords (func=0x80efe48, arg=0x80dbe98,
kw=0x0) at ceval.c:2322
#11 0x8056027 in call_trace (p_trace=0x80eace0, p_newtrace=0x80eace0,
f=0x80eacc0, msg=0x80a6e6c "line", arg=0x80b6424) at ceval.c:2190
#12 0x805502b in eval_code2 (co=0x80d27c0, globals=0x80d5ca0, locals=0x0,
args=0x80d2df4, argcount=2, kws=0x0, kwcount=0, defs=0x0, defcount=0,
owner=0x80d5b00) at ceval.c:1543
#13 0x80566a8 in call_function (func=0x80d3e58, arg=0x80d2de8, kw=0x0)
at ceval.c:2484
#14 0x805628a in PyEval_CallObjectWithKeywords (func=0x80ea540, arg=0x80d3df0,
kw=0x0) at ceval.c:2322
#15 0x8069312 in PyInstance_New (class=0x80d7778, arg=0x80d3df0, kw=0x0)
at classobject.c:473
#16 0x8056393 in call_builtin (func=0x80d7778, arg=0x80d3df0, kw=0x0)
at ceval.c:2362
#17 0x8056294 in PyEval_CallObjectWithKeywords (func=0x80d7778, arg=0x80d3df0,
kw=0x0) at ceval.c:2324
#18 0x805bebd in PyErr_NormalizeException (exc=0xbffff8f8, val=0xbffff8f4,
tb=0xbffff8f0) at errors.c:202
#19 0x805bf9a in PyErr_NormalizeException (exc=0xbffff8f8, val=0xbffff8f4,
tb=0xbffff8f0) at errors.c:227
#20 0x805bf9a in PyErr_NormalizeException (exc=0xbffff8f8, val=0xbffff8f4,
tb=0xbffff8f0) at errors.c:227
#21 0x805bf9a in PyErr_NormalizeException (exc=0xbffff8f8, val=0xbffff8f4,
tb=0xbffff8f0) at errors.c:227
#22 0x805bf9a in PyErr_NormalizeException (exc=0xbffff8f8, val=0xbffff8f4,
tb=0xbffff8f0) at errors.c:227
#23 0x805bf9a in PyErr_NormalizeException (exc=0xbffff8f8, val=0xbffff8f4,
tb=0xbffff8f0) at errors.c:227
[...]