Skip to content

gh-154701: prevent executor self-links in JIT cold exits - #155323

Merged
Fidget-Spinner merged 3 commits into
python:mainfrom
cocolato:gh-154701
Aug 13, 2026
Merged

gh-154701: prevent executor self-links in JIT cold exits#155323
Fidget-Spinner merged 3 commits into
python:mainfrom
cocolato:gh-154701

Conversation

@cocolato

@cocolato cocolato commented Aug 7, 2026

Copy link
Copy Markdown
Member

Refer: #149570 and #154701

ADD_OP(_GUARD_TYPE_ITER, 0, (uintptr_t)type);
uop_buffer_last(&ctx->out_buffer)->target = orig_target;
}
ADD_OP(_ITER_NEXT_INLINE, 0, (uintptr_t)type->tp_iternext);

After the FOR_ITER guard fails, the side exit targets the same bytecode location where the current executor is installed. _COLD_EXIT then links that exit back to the current executor itself, creating a self-loop that can never make forward progress.

Detach the self-linked executor and restore the original bytecode before falling back to Tier 1 can solve this issue.

@Fidget-Spinner Fidget-Spinner left a comment

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.

Awesome, thanks so much!

@mgorny

mgorny commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Thanks. I can confirm that it fixes my issue with main. Looks like it needs updating for 3.15, as there is no _PyFrame_StackPointerValidate() and _PyFrame_StackPointerUnvalidate() there.

@Fidget-Spinner
Fidget-Spinner merged commit 716cbae into python:main Aug 13, 2026
81 checks passed
mbeijen pushed a commit to mbeijen/cpython that referenced this pull request Aug 14, 2026
…nGH-155323)

* prevent executor self-links in JIT cold exits

* 📜🤖 Added by blurb_it.

* fix windows ci

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants