Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 4 additions & 3 deletions Python/ceval_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,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; \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Is it the same as just casting dest to _Py_CODEUNIT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a macro, where dest expands to next_instr + oparg:

INSTRUMENTED_JUMP(this_instr, next_instr + oparg, PY_MONITORING_EVENT_BRANCH_RIGHT);

(The issue has more detail on this.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I don't understand the fix. It looks like just a rename.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!

JUMP_TO_LABEL(error); \
} \
} \
Expand Down
Loading