New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-91421: Use constant value check during runtime #91422
Conversation
Thanks, this looks right to me but I'll leave others some time to speak up if there's something I missed.
This will need a NEWS entry, which you can add using blurb: https://devguide.python.org/?highlight=blurb#quick-reference. We're still working on updating some bpo references there, but I believe the blurb-it online tool has already been updated to point to GitHub.
|
The blurb-it web tool required a bpo, but the command line tool blurb was already adjusted. |
This looks good. One assembly instruction can be reduced.
| @@ -0,0 +1 @@ | |||
| Use constant value check during runtime in _Py_DecodeUTF8Ex. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Use constant value check during runtime in _Py_DecodeUTF8Ex. | |
| Fix a potential integer overflow in _Py_DecodeUTF8Ex. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted.
The left-hand side expression of the if-check can be converted to a constant by the compiler, but the addition on the right-hand side is performed during runtime. Move the addition from the right-hand side to the left-hand side by turning it into a subtraction there. Since the values are known to be large enough to not turn negative, this is a safe operation. Prevents a very unlikely integer overflow on 32 bit systems.
|
Thanks @stoeckmann for the PR, and @JelleZijlstra for merging it |
|
GH-91492 is a backport of this pull request to the 3.10 branch. |
The left-hand side expression of the if-check can be converted to a constant by the compiler, but the addition on the right-hand side is performed during runtime. Move the addition from the right-hand side to the left-hand side by turning it into a subtraction there. Since the values are known to be large enough to not turn negative, this is a safe operation. Prevents a very unlikely integer overflow on 32 bit systems. Fixes pythonGH-91421. (cherry picked from commit 0859368) Co-authored-by: Tobias Stoeckmann <stoeckmann@users.noreply.github.com>
|
GH-91493 is a backport of this pull request to the 3.9 branch. |
The left-hand side expression of the if-check can be converted to a constant by the compiler, but the addition on the right-hand side is performed during runtime. Move the addition from the right-hand side to the left-hand side by turning it into a subtraction there. Since the values are known to be large enough to not turn negative, this is a safe operation. Prevents a very unlikely integer overflow on 32 bit systems. Fixes pythonGH-91421.
The left-hand side expression of the if-check can be converted to a constant by the compiler, but the addition on the right-hand side is performed during runtime. Move the addition from the right-hand side to the left-hand side by turning it into a subtraction there. Since the values are known to be large enough to not turn negative, this is a safe operation. Prevents a very unlikely integer overflow on 32 bit systems. Fixes GH-91421. (cherry picked from commit 0859368) Co-authored-by: Tobias Stoeckmann <stoeckmann@users.noreply.github.com>
The left-hand side expression of the if-check can be converted to a constant by the compiler, but the addition on the right-hand side is performed during runtime. Move the addition from the right-hand side to the left-hand side by turning it into a subtraction there. Since the values are known to be large enough to not turn negative, this is a safe operation. Prevents a very unlikely integer overflow on 32 bit systems. Fixes GH-91421. (cherry picked from commit 0859368) Co-authored-by: Tobias Stoeckmann <stoeckmann@users.noreply.github.com>


The left-hand side expression of the if-check can be converted to a
constant by the compiler, but the addition on the right-hand side is
performed during runtime.
Move the addition from the right-hand side to the left-hand side by
turning it into a subtraction there. Since the values are known to
be large enough to not turn negative, this is a safe operation.
Prevents a very unlikely integer overflow on 32 bit systems.
Fixes issue #91421.