Skip to content

gh-152375: Fix UB in INSTRUMENTED_JUMP#152376

Open
StanFromIreland wants to merge 2 commits into
python:mainfrom
StanFromIreland:INSTRUMENTED_JUMP-ub
Open

gh-152375: Fix UB in INSTRUMENTED_JUMP#152376
StanFromIreland wants to merge 2 commits into
python:mainfrom
StanFromIreland:INSTRUMENTED_JUMP-ub

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Jun 27, 2026

Copy link
Copy Markdown
Member

I didn't add a test, I think it's too messy here, but I don't feel strongly about it. It is also already covered (non-deterministically) by test_monitoring, as that's what triggered UBSan.

@StanFromIreland

This comment was marked as off-topic.

@serhiy-storchaka

This comment was marked as off-topic.

Comment thread Python/ceval_macros.h
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!

@StanFromIreland StanFromIreland added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants