From c93cd6ea5c742e35e107f6f70d959cb222f884f3 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Tue, 16 Dec 2025 20:35:54 +0000 Subject: [PATCH 1/3] Disable JIT tracing when monitoring is enabled --- Python/bytecodes.c | 2 +- Python/generated_cases.c.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 391fa8ea2a94ec..514918fad6fb7a 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -5589,7 +5589,7 @@ dummy_func( opcode = next_instr->op.code; bool stop_tracing = (opcode == WITH_EXCEPT_START || opcode == RERAISE || opcode == CLEANUP_THROW || - opcode == PUSH_EXC_INFO || opcode == INTERPRETER_EXIT); + opcode == PUSH_EXC_INFO || opcode == INTERPRETER_EXIT || opcode >= MIN_INSTRUMENTED_OPCODE); int full = !_PyJit_translate_single_bytecode_to_trace(tstate, frame, next_instr, stop_tracing ? _DEOPT : 0); if (full) { LEAVE_TRACING(); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 94846d718308a5..351fad42c3dae8 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -11576,7 +11576,7 @@ opcode = next_instr->op.code; bool stop_tracing = (opcode == WITH_EXCEPT_START || opcode == RERAISE || opcode == CLEANUP_THROW || - opcode == PUSH_EXC_INFO || opcode == INTERPRETER_EXIT); + opcode == PUSH_EXC_INFO || opcode == INTERPRETER_EXIT || opcode >= MIN_INSTRUMENTED_OPCODE); _PyFrame_SetStackPointer(frame, stack_pointer); int full = !_PyJit_translate_single_bytecode_to_trace(tstate, frame, next_instr, stop_tracing ? _DEOPT : 0); stack_pointer = _PyFrame_GetStackPointer(frame); From edf125bd98d31e80314f9919e7742e2fce685b4e Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 16 Dec 2025 20:38:21 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2025-12-16-20-38-17.gh-issue-142448.mAFqwL.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-12-16-20-38-17.gh-issue-142448.mAFqwL.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-12-16-20-38-17.gh-issue-142448.mAFqwL.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-12-16-20-38-17.gh-issue-142448.mAFqwL.rst new file mode 100644 index 00000000000000..bcc7c1fb12d094 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-12-16-20-38-17.gh-issue-142448.mAFqwL.rst @@ -0,0 +1 @@ +Fix a bug when using monitoring with the JIT. From fe8c8f812440947a1b1b0d16b1c58ddd82ec9355 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Tue, 16 Dec 2025 21:07:37 +0000 Subject: [PATCH 3/3] fix linking back to ENTER_EXECUTOR --- Python/bytecodes.c | 11 ++++++++--- Python/generated_cases.c.h | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 514918fad6fb7a..8cc6b9d6c98d69 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -5587,9 +5587,14 @@ dummy_func( next_instr = this_instr; frame->instr_ptr = prev_instr; opcode = next_instr->op.code; - bool stop_tracing = (opcode == WITH_EXCEPT_START || - opcode == RERAISE || opcode == CLEANUP_THROW || - opcode == PUSH_EXC_INFO || opcode == INTERPRETER_EXIT || opcode >= MIN_INSTRUMENTED_OPCODE); + bool stop_tracing = ( + opcode == WITH_EXCEPT_START || + opcode == RERAISE || + opcode == CLEANUP_THROW || + opcode == PUSH_EXC_INFO || + opcode == INTERPRETER_EXIT || + (opcode >= MIN_INSTRUMENTED_OPCODE && opcode != ENTER_EXECUTOR) + ); int full = !_PyJit_translate_single_bytecode_to_trace(tstate, frame, next_instr, stop_tracing ? _DEOPT : 0); if (full) { LEAVE_TRACING(); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 351fad42c3dae8..7f0db0ad4c1379 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -11574,9 +11574,14 @@ next_instr = this_instr; frame->instr_ptr = prev_instr; opcode = next_instr->op.code; - bool stop_tracing = (opcode == WITH_EXCEPT_START || - opcode == RERAISE || opcode == CLEANUP_THROW || - opcode == PUSH_EXC_INFO || opcode == INTERPRETER_EXIT || opcode >= MIN_INSTRUMENTED_OPCODE); + bool stop_tracing = ( + opcode == WITH_EXCEPT_START || + opcode == RERAISE || + opcode == CLEANUP_THROW || + opcode == PUSH_EXC_INFO || + opcode == INTERPRETER_EXIT || + (opcode >= MIN_INSTRUMENTED_OPCODE && opcode != ENTER_EXECUTOR) + ); _PyFrame_SetStackPointer(frame, stack_pointer); int full = !_PyJit_translate_single_bytecode_to_trace(tstate, frame, next_instr, stop_tracing ? _DEOPT : 0); stack_pointer = _PyFrame_GetStackPointer(frame);