]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-142448: Disable JIT tracing when monitoring is enabled (GH-142842)
authorKen Jin <kenjin@python.org>
Tue, 23 Dec 2025 11:27:23 +0000 (19:27 +0800)
committerGitHub <noreply@github.com>
Tue, 23 Dec 2025 11:27:23 +0000 (11:27 +0000)
Misc/NEWS.d/next/Core_and_Builtins/2025-12-16-20-38-17.gh-issue-142448.mAFqwL.rst [new file with mode: 0644]
Python/bytecodes.c
Python/generated_cases.c.h

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 (file)
index 0000000..bcc7c1f
--- /dev/null
@@ -0,0 +1 @@
+Fix a bug when using monitoring with the JIT.
index da06d53f14455c013755919fc1106b54b617e4a4..5c23b2f0cc989afbf5d3c4e93831403f53dd0d15 100644 (file)
@@ -5575,9 +5575,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);
+            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();
index e562f337a0049fa7cd835d22d33cc9def70d8fb7..791df8a9750480f5b14897a57acd42781ea815ee 100644 (file)
             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);
+            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);