Skip to content

gh-149049: Fix jit binary op stack underflow#149076

Open
eendebakpt wants to merge 4 commits intopython:mainfrom
eendebakpt:fix-jit-binary-op-stack-underflow
Open

gh-149049: Fix jit binary op stack underflow#149076
eendebakpt wants to merge 4 commits intopython:mainfrom
eendebakpt:fix-jit-binary-op-stack-underflow

Conversation

@eendebakpt
Copy link
Copy Markdown
Contributor

@eendebakpt eendebakpt commented Apr 27, 2026

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 correct, but the handling of _BINARY_OP looks fragile. I've a suggestion on how to fix that.

Comment thread Python/optimizer_bytecodes.c Outdated
}
res = PyJitRef_MakeUnique(sym_new_type(ctx, &PyFloat_Type));
}
// The branches above emit a specialized binary op; every branch below
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.

Rather than emit, in each branch, a variant of _BINARY_OP and hope that you haven't missed one. Set the op to be emitted and emit it at the end.
At the start: emit_op = _BINARY_OP
For a specialization set emit_op, e.g. emit_op = _BINARY_OP_TRUEDIV_FLOAT
and then, at the end, ADD_OP(emit_op, oparg, 0);

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Apr 28, 2026

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@markshannon
Copy link
Copy Markdown
Member

Since this is fixing a reported bug, it will need a news entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants