Skip to content

Commit 00a4304

Browse files
[3.15] gh-152375: Fix undefined behaviour in the INSTRUMENTED_JUMP macro (GH-152376) (#152566)
(cherry picked from commit cdec9ac) Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent 1db0c66 commit 00a4304

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
@@ -388,14 +388,15 @@ static void dtrace_function_return(_PyInterpreterFrame *);
388388
// for an exception handler, displaying the traceback, and so on
389389
#define INSTRUMENTED_JUMP(src, dest, event) \
390390
do { \
391+
_Py_CODEUNIT *_dest = (dest); \
391392
if (tstate->tracing) {\
392-
next_instr = dest; \
393+
next_instr = _dest; \
393394
} else { \
394395
_PyFrame_SetStackPointer(frame, stack_pointer); \
395-
next_instr = _Py_call_instrumentation_jump(this_instr, tstate, event, frame, src, dest); \
396+
next_instr = _Py_call_instrumentation_jump(this_instr, tstate, event, frame, src, _dest); \
396397
stack_pointer = _PyFrame_GetStackPointer(frame); \
397398
if (next_instr == NULL) { \
398-
next_instr = (dest)+1; \
399+
next_instr = _dest + 1; \
399400
JUMP_TO_LABEL(error); \
400401
} \
401402
} \

0 commit comments

Comments
 (0)