-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-136421: Fix crash in _datetime when initialized/finalized concurrently #136620
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
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.
Yeah, this feels like a really big hack.
But, won't this still initialize the types concurrently anyway? I don't think that's thread-safe, even if the main interpreter sets some of the initial values. AFAICT, the current assumption is that only one interpreter can initialize a static type at a time (because the type lock is per-interpreter, not runtime-wide).
I left a comment in your PR: #136583 (comment)
The runtime state has the initial values as common type data. OTOH, non-initial values such as |
According to #129824, the managed static builtin types have the issue despite the fact that the main interpreter initializes them first. Then, the managed static extension types also have the same issue that cannot be fixed by this PR and yours. The same will go for |
Ugh, I thought that interpreter initialization held the runtime lock. I'll investigate further later this week. We can probably avoid changes to That said, I do still think |
The managed static extension type has been introduced just to work around the issue of the capsule C API, so you need to mention there why you cannot resolve the issue first. |
An alternative could be to immortalize some heap-types and expose them in the capsule. |
Sounds promising, changing the |
But a heaptype usually holds a corresponding module, which needs to be updated. Or, perhaps immortalize the module as well? |
I haven't fully fleshed out the idea yet. I'm thinking we could make |
Closing, as #136583 seems to be backportable. |
_datetime
in sub-interpreters in the same time may crash the process #136421