Skip to content

Commit cdec9ac

Browse files
gh-152375: Fix undefined behaviour in the INSTRUMENTED_JUMP macro (#152376)
1 parent 6d209cb commit cdec9ac

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
@@ -389,14 +389,15 @@ static void dtrace_function_return(_PyInterpreterFrame *);
389389
// for an exception handler, displaying the traceback, and so on
390390
#define INSTRUMENTED_JUMP(src, dest, event) \
391391
do { \
392+
_Py_CODEUNIT *_dest = (dest); \
392393
if (tstate->tracing) {\
393-
next_instr = dest; \
394+
next_instr = _dest; \
394395
} else { \
395396
_PyFrame_SetStackPointer(frame, stack_pointer); \
396-
next_instr = _Py_call_instrumentation_jump(this_instr, tstate, event, frame, src, dest); \
397+
next_instr = _Py_call_instrumentation_jump(this_instr, tstate, event, frame, src, _dest); \
397398
stack_pointer = _PyFrame_GetStackPointer(frame); \
398399
if (next_instr == NULL) { \
399-
next_instr = (dest)+1; \
400+
next_instr = _dest + 1; \
400401
JUMP_TO_LABEL(error); \
401402
} \
402403
} \

0 commit comments

Comments
 (0)