]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-152375: Fix undefined behaviour in the `INSTRUMENTED_JUMP` macro (GH-152376...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 29 Jun 2026 09:40:05 +0000 (11:40 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Jun 2026 09:40:05 +0000 (09:40 +0000)
(cherry picked from commit cdec9acd63c33d9b822700de8f63eb94d86e1c93)

Co-authored-by: Stan Ulbrych <stan@python.org>
Misc/NEWS.d/next/Core_and_Builtins/2026-06-27-10-05-12.gh-issue-152375.L-ZBk6.rst [new file with mode: 0644]
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 (file)
index 0000000..db6ae30
--- /dev/null
@@ -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.
index 4a878d6dff4353b663c4d9190320a07128c91a63..95a8e719d4d0d1c98c6298c70abb470123132373 100644 (file)
@@ -320,14 +320,15 @@ GETITEM(PyObject *v, Py_ssize_t i) {
 // 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(this_instr, tstate, event, frame, src, dest); \
+        next_instr = _Py_call_instrumentation_jump(this_instr, tstate, event, frame, src, _dest); \
         stack_pointer = _PyFrame_GetStackPointer(frame); \
         if (next_instr == NULL) { \
-            next_instr = (dest)+1; \
+            next_instr = _dest + 1; \
             JUMP_TO_LABEL(error); \
         } \
     } \