From 3fa92e7c55d74aea062c4b32d895e84d7aaa3bce Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Thu, 18 Jun 2026 20:58:12 +0900 Subject: [PATCH] gh-151229: Finalize JIT tracer in test eval-frame stub (gh-151609) --- Modules/_testinternalcapi/interpreter.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/_testinternalcapi/interpreter.c b/Modules/_testinternalcapi/interpreter.c index 99dcd18393fb..4afa028cd875 100644 --- a/Modules/_testinternalcapi/interpreter.c +++ b/Modules/_testinternalcapi/interpreter.c @@ -18,8 +18,13 @@ int Test_EvalFrame_Resumes, Test_EvalFrame_Loads; static int stop_tracing_and_jit(PyThreadState *tstate, _PyInterpreterFrame *frame) { - (void)(tstate); (void)(frame); + // Don't actually JIT-compile in this test eval-frame, but we still must + // finalize the tracer so the thread-global is_tracing flag is reset. + // Otherwise a trace started inside this duplicated interpreter loop + // (reachable under low JIT thresholds, e.g. PYTHON_JIT_STRESS=1) would + // leave is_tracing stuck true and permanently disable the JIT. + _PyJit_FinalizeTracing(tstate, 0); return 0; } #endif -- 2.47.3