Skip to content
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-113710: Fix optimization of globals using _CHECK_FUNCTION #116460

Merged
merged 2 commits into from
Mar 8, 2024

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Mar 7, 2024

#116410 added an obvious bug: I didn't update the pointers used.
But there is more subtle bug: Using pointers rather than version numbers risks a new function appearing to be the old one.

This PR fixes both bugs.

@Fidget-Spinner
Copy link
Member

lgtm but I will wait for Guido to review too

assert(((PyFunctionObject *)frame->f_funcobj)->func_globals == globals);
PyFunctionObject *function = (PyFunctionObject *)frame->f_funcobj;
assert(PyFunction_Check(function));
assert(function->func_builtins == builtins);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: these are read-only attributes so this precondition should hold.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@markshannon markshannon merged commit 0003285 into python:main Mar 8, 2024
52 checks passed
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
@markshannon markshannon deleted the fix-check-function branch August 6, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants