https://github.com/python/cpython/commit/16381511ebcea041bf56db40e3f5675d27306c25
commit: 16381511ebcea041bf56db40e3f5675d27306c25
branch: 3.13
author: Stan Ulbrych <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-06-29T10:04:56Z
summary:

[3.13] gh-152375: Fix undefined behaviour in the `INSTRUMENTED_JUMP` macro 
(GH-152376) (#152577)

(cherry picked from commit cdec9acd63c33d9b822700de8f63eb94d86e1c93)

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2026-06-27-10-05-12.gh-issue-152375.L-ZBk6.rst
M Python/ceval_macros.h

diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-27-10-05-12.gh-issue-152375.L-ZBk6.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-27-10-05-12.gh-issue-152375.L-ZBk6.rst
new file mode 100644
index 000000000000000..db6ae3060d8328f
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-27-10-05-12.gh-issue-152375.L-ZBk6.rst
@@ -0,0 +1,2 @@
+Fix undefined behaviour when a :mod:`sys.monitoring` callback raised an
+exception while the program was following a branch or loop.
diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h
index 1ab83856fd99041..ab96ebdfea294cc 100644
--- a/Python/ceval_macros.h
+++ b/Python/ceval_macros.h
@@ -359,14 +359,15 @@ do { \
 // for an exception handler, displaying the traceback, and so on
 #define INSTRUMENTED_JUMP(src, dest, event) \
 do { \
+    _Py_CODEUNIT *_dest = (dest); \
     if (tstate->tracing) {\
-        next_instr = dest; \
+        next_instr = _dest; \
     } else { \
         _PyFrame_SetStackPointer(frame, stack_pointer); \
-        next_instr = _Py_call_instrumentation_jump(tstate, event, frame, src, 
dest); \
+        next_instr = _Py_call_instrumentation_jump(tstate, event, frame, src, 
_dest); \
         stack_pointer = _PyFrame_GetStackPointer(frame); \
         if (next_instr == NULL) { \
-            next_instr = (dest)+1; \
+            next_instr = _dest + 1; \
             goto error; \
         } \
     } \

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to