Skip to content

gh-146092: Fix error handling in _BINARY_OP_ADD_UNICODE opcode - #146117

Merged
vstinner merged 2 commits into
python:mainfrom
vstinner:eval_err
Mar 18, 2026
Merged

vstinner merged 2 commits into
python:mainfrom
vstinner:eval_err

Conversation

@vstinner

@vstinner vstinner commented Mar 18, 2026 •

Copy link
Copy Markdown
Member

Fix also error handling in _BINARY_OP_ADD_FLOAT,
_BINARY_OP_SUBTRACT_FLOAT and _BINARY_OP_MULTIPLY_FLOAT opcodes. PyStackRef_FromPyObjectSteal() must not be called with a NULL pointer.

Fix also error handling in _BINARY_OP_ADD_FLOAT,
_BINARY_OP_SUBTRACT_FLOAT and _BINARY_OP_MULTIPLY_FLOAT opcodes.
PyStackRef_FromPyObjectSteal() must not be called with a NULL
pointer.
@vstinner

Copy link
Copy Markdown
Member Author

I don't know well Python/bytecodes.c DSL, so I'm not sure if inputs are cleared properly on error.

Python 3.14 is also affected by the bug for _BINARY_OP_ADD_FLOAT, _BINARY_OP_SUBTRACT_FLOAT and _BINARY_OP_MULTIPLY_FLOAT opcodes (_BINARY_OP_ADD_UNICODE is not affected), but it needs a different fix. Once this fix will be merged, I will write a different one for 3.14.

cc @Fidget-Spinner @corona10

@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.

Thanks

@Fidget-Spinner

Copy link
Copy Markdown
Member

I think you accidentally committed an out of date test_frozenmain?

@vstinner

Copy link
Copy Markdown
Member Author

I think you accidentally committed an out of date test_frozenmain?

I don't know what happened, but Programs/test_frozenmain.h was regenerated somehow. I fixed the issue.

@vstinner

Copy link
Copy Markdown
Member Author

Fix for the 3.14 branch: #146119.

@vstinner
vstinner merged commit 1e4ed93 into python:main Mar 18, 2026
69 checks passed
@vstinner
vstinner deleted the eval_err branch March 18, 2026 16:23
@miss-islington-app

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @vstinner, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1e4ed932109c4f8ee4f43bc3e6fdb7710a3606bd 3.14
@miss-islington-app

Copy link
Copy Markdown

Sorry, @vstinner, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1e4ed932109c4f8ee4f43bc3e6fdb7710a3606bd 3.13
@vstinner vstinner removed needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Mar 18, 2026
@vstinner

Copy link
Copy Markdown
Member Author

@serhiy-storchaka added needs backport to 3.13 needs backport to 3.14 labels

As I wrote previously, the 3.14 branch needs a different fix. I wrote the PR gh-146119 for that.

Python 3.13 is not affected by the bug. PyStackRef_FromPyObjectSteal() doesn't exist in Python 3.13 (the function was added to Python 3.14).

@vstinner

Copy link
Copy Markdown
Member Author

PR merged. Thanks for your review @Fidget-Spinner.

ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
…ython#146117)

Fix also error handling in _BINARY_OP_ADD_FLOAT,
_BINARY_OP_SUBTRACT_FLOAT and _BINARY_OP_MULTIPLY_FLOAT opcodes.
PyStackRef_FromPyObjectSteal() must not be called with a NULL
pointer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants