-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-116098: Clean up frame allocation code and remove the invalid sneaky frame test #116687
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-116098: Clean up frame allocation code and remove the invalid sneaky frame test #116687
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.
Thanks!
Probably not worth backporting. |
// Just pretend that we have an owned, cleared frame so frame_dealloc | ||
// doesn't make the situation worse: | ||
f->f_frame = (_PyInterpreterFrame *)f->_f_frame_data; | ||
f->f_frame->owner = FRAME_CLEARED; |
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.
We should also remove the corresponding assert(frame->owner != FRAME_CLEARED)
statements, especially since FRAME_CLEARED
was never a valid member of enum _frameowner
(it’s from enum _framestate
).
GH-124148) The `owner` field of `_PyInterpreterFrame` is supposed to be a member of `enum _frameowner`, but `FRAME_CLEARED` is a member of `enum _framestate`. At present, it happens that `FRAME_CLEARED` is not numerically equal to any member of `enum _frameowner`, but that could change in the future. The code that incorrectly assigned `owner = FRAME_CLEARED` was deleted in commit a53cc3f (GH-116687). Remove the incorrect checks for `owner != FRAME_CLEARED` as well.
pythonGH-124148) The `owner` field of `_PyInterpreterFrame` is supposed to be a member of `enum _frameowner`, but `FRAME_CLEARED` is a member of `enum _framestate`. At present, it happens that `FRAME_CLEARED` is not numerically equal to any member of `enum _frameowner`, but that could change in the future. The code that incorrectly assigned `owner = FRAME_CLEARED` was deleted in commit a53cc3f (pythonGH-116687). Remove the incorrect checks for `owner != FRAME_CLEARED` as well.
After a discussion with @brandtbucher , we believe the test is not testing what it's supposed to anymore. No new frame is created during the frame allocation and the test lost its meaning. Under no circumstance this test is valid or checking something reasonable. So we should just remove this test.
The fundamental reason the test is invalid is that the current frame allocation code is immune from being interrupted by Python code that can somehow create the same frame object. So we also remove the dead code in frame allocation, and replace it with an assert and some comments.
There's no user observable behavior changes so I'll skip the news, unless someone disagrees.
test_frame
fails when running with-R 3:3
argument #116098