Repository navigation
test_pdb crashes when run after test_sys_settrace #108976
Description
Activity
- addedtestsTests in the Lib/test dirTests in the Lib/test dirtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump3.12only security fixesonly security fixes3.13only security fixesonly security fixes
on Sep 6, 2023 test_pdbonly crashes afterRaisingTraceFuncTestCase.test_line_event_raises_before_opcode_eventor after any ofTraceOpcodesTestCasecases fromtest_sys_settrace.$ ./python -m test -v test_sys_settrace test_pdb -m test_pdb_display_command -m test.test_sys_settrace.RaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event $ ./python -m test -v test_sys_settrace test_pdb -m test_pdb_display_command -m test.test_sys_settrace.TraceOpcodesTestCase.test_01_basicThese tests also occur in #108982, so this all may be symptoms of the same bug.
I'm able to reduce the MRE:
import sys sys._getframe().f_trace_opcodes = True breakpoint() a = 1
It will bring up the pdb console, and you can just
cto trigger the SegFault.The crash is a bit tricky, and affects more than
sys.settrace-sys.monitoringalso suffers from it.The fundamental reason was when
INSTRUCTIONandLINEevents are both set, andINSTRUMENTATIONis turned off inLINEevent callback, the system got confused. InINSTRUMENTED_LINE, it will try to get the next opcode and would be fed a wrong one -INSTRUMENTED_INSTRUCTIONby the current design. However, the instrumentation is already stripped, which would eventually cause issues that lead to a SegFault.I have a fix which simply checks if this case happens when opcode is requested from
INSTRUMENTED_LINEand use the original opcode for the instruction.This might not be the best way to fix it, but it's clean and simple. If @markshannon has a better idea, I can do something different.
- added a commit that references this issue
on Sep 12, 2023 This is fixed now, both in main and 3.12
- moved this from Todo to Done in Release and Deferred blockers 🚫
on Sep 12, 2023
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Crash report
Just run two tests sequentially:
It is only reproducible in 3.12+.
Linked PRs