close
Skip to content

gh-149459: Fix segfault when _LOAD_SPECIAL guard deoptimizes#149478

Merged
kumaraditya303 merged 6 commits intopython:mainfrom
cocolato:gh-149459
May 8, 2026
Merged

gh-149459: Fix segfault when _LOAD_SPECIAL guard deoptimizes#149478
kumaraditya303 merged 6 commits intopython:mainfrom
cocolato:gh-149459

Conversation

@cocolato
Copy link
Copy Markdown
Member

@cocolato cocolato commented May 7, 2026

LOAD_SPECIAL expands as:
_RECORD_TOS_TYPE + _INSERT_NULL + _LOAD_SPECIAL
_INSERT_NULL alters the actual stack structure:
Before modification: [..., self]
After modification: [..., NULL, self]
The optimizer has introduced _GUARD_TYPE_VERSION. If a guard is placed after _INSERT_NULL, and the guard fails resulting in a side exit, the interpreter will deopt back to the original LOAD_SPECIAL. However, by this point, the stack has already been modified by _INSERT_NULL to [..., NULL, self].

@read-the-docs-community
Copy link
Copy Markdown

Copy link
Copy Markdown
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for fixing this

@kumaraditya303 kumaraditya303 added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label May 8, 2026
@kumaraditya303 kumaraditya303 enabled auto-merge (squash) May 8, 2026 10:56
@kumaraditya303 kumaraditya303 merged commit c341e34 into python:main May 8, 2026
74 of 75 checks passed
@miss-islington-app
Copy link
Copy Markdown

Thanks @cocolato for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 8, 2026

GH-149552 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label May 8, 2026
kumaraditya303 pushed a commit that referenced this pull request May 8, 2026
…GH-149478) (#149552)

gh-149459: Fix segfault when `_LOAD_SPECIAL` guard deoptimizes (GH-149478)
(cherry picked from commit c341e34)

Co-authored-by: Hai Zhu <haiizhu@outlook.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