gh-143123: Protect against recursive tracer calls/finalization (GH-143126)

* Stronger check for recursive traces

* Add a stop_tracing field

* Stop early when tracing exceptions
This commit is contained in:
Ken Jin 2026-01-14 20:23:14 +08:00 committed by GitHub
parent 6db952eae9
commit e370c8db52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 100 additions and 31 deletions

View file

@ -5620,6 +5620,9 @@ dummy_func(
#else
assert(_PyErr_Occurred(tstate));
#endif
SAVE_STACK();
STOP_TRACING();
RELOAD_STACK();
/* Log traceback info. */
assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
@ -5634,6 +5637,9 @@ dummy_func(
}
spilled label(exception_unwind) {
SAVE_STACK();
STOP_TRACING();
RELOAD_STACK();
/* We can't use frame->instr_ptr here, as RERAISE may have set it */
int offset = INSTR_OFFSET()-1;
int level, handler, lasti;