[3.15] gh-152375: Fix undefined behaviour in the INSTRUMENTED_JUMP macro (GH-152376) (#152566)

(cherry picked from commit cdec9acd63)

Co-authored-by: Stan Ulbrych <stan@python.org>
This commit is contained in:
Miss Islington (bot)
2026-06-29 11:54:27 +02:00
committed by GitHub
parent 1db0c66246
commit 00a43044d8
2 changed files with 6 additions and 3 deletions
@@ -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.
+4 -3
View File
@@ -388,14 +388,15 @@ static void dtrace_function_return(_PyInterpreterFrame *);
// 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); \
} \
} \