gh-118746: Fix crash in frame_getlocals#118748
Merged
gvanrossum merged 2 commits intopython:mainfrom May 8, 2024
Merged
Conversation
gvanrossum
reviewed
May 8, 2024
Member
gvanrossum
left a comment
There was a problem hiding this comment.
Please also fix the identical code snippet in _PyFrame_GetLocals.
gvanrossum
approved these changes
May 8, 2024
Member
gvanrossum
left a comment
There was a problem hiding this comment.
This LGTM -- can someone test with sklearn? Also, I'm not sure if this now has a race condition in free-threading mode. Then again, if this is a race condition, the old (pre-pep-667) code also had the same race condition, in _PyFrame_GetLocals.
Contributor
|
This appears to fix the crash for me (tested in a debug, free-threaded build because that's what my scikit-learn deps were built for) |
Contributor
|
Fixes it for me in a similar non free-threaded build to the one I used in #118746. |
Member
|
Also confirmed the sklearn test no longer segfaults for me with this PR applied. |
Member
|
Thanks everyone! |
SonicField
pushed a commit
to SonicField/cpython
that referenced
this pull request
May 8, 2024
…ython#118748) We don't know how to create an unoptimized frame with f_locals == NULL, but they are seen in the wild, and this fixes the crash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We don't know the root cause for this yet. For now we create an empty dict for
frame->f_localsto avoid the crash.