-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-102509: Start initializing ob_digit
of _PyLongValue
#102510
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
Conversation
@illia-v Can you provide Python code that reproduces the access of the uninitialized value? The theory is that it shouldn't matter that this digit is uninitialized when I'm not convinced that |
I think I see. In the case So I think this counts as a false positive, and no fix is necessary. |
Pinging @markshannon, who introduced this logic: Mark, I don't see any issue here, and think this should be closed. Agreed? |
It may still be worth adding a comment in |
To be clear, if this weren't a hot path then I'd probably add the extra initialization just for peace of mind, but |
This does seem to be a real bug.
Are you sure about this? I expect this code to go when #101291 is implemented, so we might as well fix it for now. |
Fairly sure, yes. :-) We either get an uninitialised value (which is fine), or a trap representation (which is not), but trap representations in integers are not a practical problem these days. Here's a good Stack Overflow answer by Eric Postpischil that quotes chapter and verse: https://stackoverflow.com/a/66840190/270986 |
It should be fine - at that point, the uninitialised value is some value of type |
I am not very familiar with this part of CPython source, but comments and code itself mention not only Lines 25 to 34 in 3adb23a
|
Yes, but if If this goes in, we should have a comment explaining why the extra initialization is necessary (possibly with a pointer to this PR or the associated issue), and this comment in My preferred solution here would be to go back to a more obviously correct spelling for |
The performance impact of this change is in the noise. |
We expect the internals of |
Thanks @illia-v for the PR, and @markshannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
GH-107464 is a backport of this pull request to the 3.12 branch. |
…honGH-102510) (cherry picked from commit fc130c4) Co-authored-by: Illia Volochii <illia.volochii@gmail.com>
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51574 detected an uninitialized value.
I can reproduce the error by running
CC=clang ./configure --with-memory-sanitizer && make -j12
locally. When I initializeresult->long_value.ob_digit[0]
explicitly, the error looks to be fixed (actually a new error similar to one described in #91043 (comment) appears.)