-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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-118746: Fix crash in frame_getlocals #118748
Conversation
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.
Please also fix the identical code snippet in _PyFrame_GetLocals
.
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.
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
.
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) |
Fixes it for me in a similar non free-threaded build to the one I used in #118746. |
Also confirmed the sklearn test no longer segfaults for me with this PR applied. |
Thanks everyone! |
…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.
We don't know the root cause for this yet. For now we create an empty dict for
frame->f_locals
to avoid the crash.