Repository navigation
Raising during line tracing events causes assertion failures when opcode tracing is enabled #96864
Copy link
Copy link
Closed
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Example:
import sys
def tracefunc(frame, event, arg):
frame.f_trace_opcodes = True
if event == 'line':
1 / 0
return tracefunc
def main():
pass
sys.settrace(tracefunc)
main()3.12.0a0 (main:e47b96c44f) crashes with the following message:
$ ../cpython/python -Xfaulthandler crash.py
python: Python/ceval.c:1107: _PyEval_EvalFrameDefault: Assertion `!_PyErr_Occurred(tstate)' failed.
Fatal Python error: Aborted
Current thread 0x00007f06c1a47740 (most recent call first):
File "/home/.../crash.py", line 13 in <module>
Aborted (core dumped)
Stack trace:
#0 0x00007ffff7d3f34c in __pthread_kill_implementation () from /usr/lib/libc.so.6
#1 0x00007ffff7cf24b8 in raise () from /usr/lib/libc.so.6
#2 0x00007ffff7cdc534 in abort () from /usr/lib/libc.so.6
#3 0x00007ffff7cdc45c in __assert_fail_base.cold () from /usr/lib/libc.so.6
#4 0x00007ffff7ceb116 in __assert_fail () from /usr/lib/libc.so.6
#5 0x00005555557b7497 in _PyEval_EvalFrameDefault (tstate=0x555555b46aa8 <_PyRuntime+180616>, frame=0x7ffff7fbc020, throwflag=0)
at Python/ceval.c:1107
#6 0x00005555557c9d3b in _PyEval_EvalFrame (tstate=tstate@entry=0x555555b46aa8 <_PyRuntime+180616>, frame=frame@entry=0x7ffff7fbc020,
throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:95
#7 0x00005555557c9e53 in _PyEval_Vector (tstate=tstate@entry=0x555555b46aa8 <_PyRuntime+180616>, func=func@entry=0x7ffff77e5e90,
locals=locals@entry=0x7ffff77895b0, args=args@entry=0x0, argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at Python/ceval.c:5789
#8 0x00005555557c9f69 in PyEval_EvalCode (co=co@entry=0x7ffff79a1fe0, globals=globals@entry=0x7ffff77895b0, locals=locals@entry=0x7ffff77895b0)
at Python/ceval.c:591
#9 0x00005555558246b3 in run_eval_code_obj (tstate=tstate@entry=0x555555b46aa8 <_PyRuntime+180616>, co=co@entry=0x7ffff79a1fe0,
globals=globals@entry=0x7ffff77895b0, locals=locals@entry=0x7ffff77895b0) at Python/pythonrun.c:1713
#10 0x0000555555824778 in run_mod (mod=mod@entry=0x555555c3fb10, filename=filename@entry=0x7ffff77f1310, globals=globals@entry=0x7ffff77895b0,
locals=locals@entry=0x7ffff77895b0, flags=flags@entry=0x7fffffffe548, arena=arena@entry=0x7ffff77ec040) at Python/pythonrun.c:1734
#11 0x0000555555824840 in pyrun_file (fp=fp@entry=0x555555b8f530, filename=filename@entry=0x7ffff77f1310, start=start@entry=257,
globals=globals@entry=0x7ffff77895b0, locals=locals@entry=0x7ffff77895b0, closeit=closeit@entry=1, flags=0x7fffffffe548)
at Python/pythonrun.c:1629
#12 0x0000555555827664 in _PyRun_SimpleFileObject (fp=fp@entry=0x555555b8f530, filename=filename@entry=0x7ffff77f1310, closeit=closeit@entry=1,
flags=flags@entry=0x7fffffffe548) at Python/pythonrun.c:439
#13 0x0000555555827823 in _PyRun_AnyFileObject (fp=fp@entry=0x555555b8f530, filename=filename@entry=0x7ffff77f1310, closeit=closeit@entry=1,
flags=flags@entry=0x7fffffffe548) at Python/pythonrun.c:78
#14 0x0000555555845d79 in pymain_run_file_obj (program_name=program_name@entry=0x7ffff77f1380, filename=filename@entry=0x7ffff77f1310,
skip_source_first_line=0) at Modules/main.c:360
#15 0x0000555555845ea1 in pymain_run_file (config=config@entry=0x555555b2b818 <_PyRuntime+69368>) at Modules/main.c:379
#16 0x0000555555846637 in pymain_run_python (exitcode=exitcode@entry=0x7fffffffe6c4) at Modules/main.c:610
#17 0x00005555558468e3 in Py_RunMain () at Modules/main.c:689
#18 0x000055555584695a in pymain_main (args=args@entry=0x7fffffffe720) at Modules/main.c:719
#19 0x0000555555846a20 in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:743
#20 0x000055555564c742 in main (argc=<optimized out>, argv=<optimized out>) at ./Programs/python.c:153.10.7 prints this traceback:
$ python -Xfaulthandler crash.py
Traceback (most recent call last):
File "/home/.../crash.py", line 10, in main
pass
File "/home/.../crash.py", line 6, in tracefunc
1 / 0
ZeroDivisionError: division by zero
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/.../crash.py", line 13, in <module>
main()
SystemError: _PyEval_EvalFrameDefault returned a result with an exception set
OS version: Linux 5.16.9-arch1-1 x86_64.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Projects
- StatusShow more project fieldsDone
Activity
brandtbucher commentedon Sep 16, 2022
Oof, thanks for the report. I'm looking at it now.
@pablogsal, marking as a 3.11 release blocker until I can find out if the assertion failures in debug mode are new or not.
brandtbucher commentedon Sep 16, 2022
Minimal reproducer:
Verified that 3.10, 3.11, and main all abort when compiled in debug mode. In release mode, 3.10 raises
SystemError, while 3.11 and main both behave as expected. So this isn't new in 3.11 (if anything, the behavior in release mode improved), and the debug mode fix can probably wait for 3.11.1. Your call, @pablogsal.Either way, I'll start working on fixes for all three.
[-]Python/ceval.c:1107: _PyEval_EvalFrameDefault: Assertion `!_PyErr_Occurred(tstate)' failed[/-][+]Raising during `opcode`/`line` tracing events causes assertion failures[/+][-]Raising during `opcode`/`line` tracing events causes assertion failures[/-][+]Raising during `line` tracing events causes assertion failures when opcode tracing is enabled[/+][-]Raising during `line` tracing events causes assertion failures when opcode tracing is enabled[/-][+]Raising during line tracing events causes assertion failures when opcode tracing is enabled[/+]GH-96864: Check for error between line and opcode events (GH-96880)
pythonGH-96864: Check for error between line and opcode events (pytho…
GH-96864: Check for error between line and opcode events (GH-96880)
[3.10] pythonGH-96864: Check for error between line and opcode events (…
[3.10] GH-96864: Check for error between line and opcode events (GH-9…
brandtbucher commentedon Sep 20, 2022
Thanks again for the report!