Skip to content

Commit 1638151

Browse files
[3.13] gh-152375: Fix undefined behaviour in the INSTRUMENTED_JUMP macro (GH-152376) (#152577)
(cherry picked from commit cdec9ac)
1 parent 5f5dbfb commit 1638151

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix undefined behaviour when a :mod:`sys.monitoring` callback raised an
2+
exception while the program was following a branch or loop.

Python/ceval_macros.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,15 @@ do { \
359359
// for an exception handler, displaying the traceback, and so on
360360
#define INSTRUMENTED_JUMP(src, dest, event) \
361361
do { \
362+
_Py_CODEUNIT *_dest = (dest); \
362363
if (tstate->tracing) {\
363-
next_instr = dest; \
364+
next_instr = _dest; \
364365
} else { \
365366
_PyFrame_SetStackPointer(frame, stack_pointer); \
366-
next_instr = _Py_call_instrumentation_jump(tstate, event, frame, src, dest); \
367+
next_instr = _Py_call_instrumentation_jump(tstate, event, frame, src, _dest); \
367368
stack_pointer = _PyFrame_GetStackPointer(frame); \
368369
if (next_instr == NULL) { \
369-
next_instr = (dest)+1; \
370+
next_instr = _dest + 1; \
370371
goto error; \
371372
} \
372373
} \

0 commit comments

Comments
 (0)