-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-136421: Fix crash when _datetime is been initialized in multiple sub-interpreters #136422
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
base: main
Are you sure you want to change the base?
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.
I think we need a more fundamental fix that prevents static types from being initialized concurrently. This is sort of a known issue, see #129817.
@@ -7344,9 +7344,13 @@ init_static_types(PyInterpreterState *interp, int reloading) | |||
|
|||
/* Bases classes must be initialized before subclasses, | |||
* so capi_types must have the types in the appropriate order. */ | |||
static PyMutex mutex = {0}; |
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.
If the assumption is that this can run concurrently, then we need to also protect the assignments to tp_base
above.
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.
I forgot to clarify that I don't think this should be done with a mutex. An atomic global initialized
variable should work and prevent double-initialization of the type.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
_datetime
in sub-interpreters in the same time may crash the process #136421