-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
gh-127065: Make methodcaller thread-safe and re-entrant (v2) #127746
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
Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
Py_VISIT(mc->kwds); | ||
Py_VISIT(mc->vectorcall_args); | ||
Py_VISIT(mc->vectorcall_kwnames); |
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.
Note mc->vectorcall_kwnames
is a tuple of strings, but the strings can be subclasses of str
, so we need to visit this.
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.
Looks good. A few small comments below
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.
LGTM. Thanks for fixing this!
…GH-127746) The function `operator.methodcaller` was not thread-safe since the additional of the vectorcall method in pythongh-89013. In the free threading build the issue is easy to trigger, for the normal build harder. This makes the `methodcaller` safe by: * Replacing the lazy initialization with initialization in the constructor. * Using a stack allocated space for the vectorcall arguments and falling back to `tp_call` for calls with more than 8 arguments.
See #127245 for details.
methodcaller
is not thread-safe (or re-entrant) #127065