-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-130851: Don't crash when deduping unusual code constants. #130853
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
The bytecode compiler only generates a few different types of constants, like str, int, tuple, slices, etc. Users can construct code objects with various unusual constants, including ones that are not hashable or not even constant. The free threaded build previously crashed with a fatal error when confronted with these constants. Instead, treat distinct objects of otherwise unhandled types as not equal for the purposes of deduplication.
// provide their own constants, when constructing code objects via | ||
// types.CodeType(). If the user-provided constant is unhashable, we | ||
// use the memory address of the object as a fallback hash value. | ||
PyErr_Clear(); |
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.
I'm of two minds on whether this should warn or not... I guess that's part of a bigger discussion of whether we should try to support this pretty absurd thing of stuffing arbitrary things in code objects. If we don't want to support it, this should probably warn?
Thanks @colesbury for the PR, and @Yhg1s for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…thonGH-130853) The bytecode compiler only generates a few different types of constants, like str, int, tuple, slices, etc. Users can construct code objects with various unusual constants, including ones that are not hashable or not even constant. The free threaded build previously crashed with a fatal error when confronted with these constants. Instead, treat distinct objects of otherwise unhandled types as not equal for the purposes of deduplication. (cherry picked from commit 2905690) Co-authored-by: Sam Gross <[email protected]>
GH-130880 is a backport of this pull request to the 3.13 branch. |
…H-130853) (#130880) The bytecode compiler only generates a few different types of constants, like str, int, tuple, slices, etc. Users can construct code objects with various unusual constants, including ones that are not hashable or not even constant. The free threaded build previously crashed with a fatal error when confronted with these constants. Instead, treat distinct objects of otherwise unhandled types as not equal for the purposes of deduplication. (cherry picked from commit 2905690) Co-authored-by: Sam Gross <[email protected]>
I think I broke the nogil refleaks buildbot, probably because of the immortalization in the added test: https://buildbot.python.org/#/builders/1610/builds/966 I'll submit a follow up PR. |
|
…thon#130853) The bytecode compiler only generates a few different types of constants, like str, int, tuple, slices, etc. Users can construct code objects with various unusual constants, including ones that are not hashable or not even constant. The free threaded build previously crashed with a fatal error when confronted with these constants. Instead, treat distinct objects of otherwise unhandled types as not equal for the purposes of deduplication.
The bytecode compiler only generates a few different types of constants, like str, int, tuple, slices, etc. Users can construct code objects with various unusual constants, including ones that are not hashable or not even constant.
The free threaded build previously crashed with a fatal error when confronted with these constants. Instead, treat distinct objects of otherwise unhandled types as not equal for the purposes of deduplication.