FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-136421: Fix crash when _datetime is been initialized in multiple sub-interpreters by aisk · Pull Request #136422 · python/cpython · GitHub

/ cpython Public

gh-136421: Fix crash when _datetime is been initialized in multiple sub-interpreters - #136422

Closed
aisk wants to merge 5 commits into
python:mainfrom
aisk:datetime-subinterpreter-initialize
Closed

gh-136421: Fix crash when _datetime is been initialized in multiple sub-interpreters#136422
aisk wants to merge 5 commits into
python:mainfrom
aisk:datetime-subinterpreter-initialize

Conversation

aisk commented Jul 8, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

aisk requested review from abalkin and pganssle as code owners July 8, 2025 14:01
aisk changed the title gh-136421: Fix crash when _datetime is been initialized in multiple sub-interpre… gh-136421: Fix crash when _datetime is been initialized in multiple sub-interpreters Jul 8, 2025
Comment thread Modules/_datetimemodule.c

ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Comment thread Modules/_datetimemodule.c Outdated

bedevere-app Bot commented Jul 8, 2025

Copy link
Copy Markdown

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Comment thread Modules/_datetimemodule.c Outdated

ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please add a test. I'm still not fully convinced that this is the right approach; _PyStaticType_InitForExtension should be thread-safe on its own, or at least in the places where it's used.

I think the problem is that _datetime is special and has static types (because they need to be exposed via the capsule). Instead of initializing them in the module's execution function, let's do it during interpreter initialization in pycore_interp_init.

…e-136421.uzieFA.rst

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

neonene commented Jul 12, 2025

Copy link
Copy Markdown
Contributor

An alternative would be to make _interpreters module import _datetime when running the main interpreter.

aisk commented Jul 12, 2025

Copy link
Copy Markdown
Member Author

Due to issue #136423, importing _datetime into a sub-interpreter concurrently still results in a crash, even after this change, so it's hard to write a test. I also feel that this is not the correct way to fix the root cause, and this PR is more like a workaround.

I'll continue to investigate #136423, as they appear to have the same root cause. Maybe we can find a better way to address them. So maybe we can wait sometime before continue this PR?

Copy link
Copy Markdown
Member

I've put up #136583 as an alternative that avoids locking, at the cost of moving _datetime to a static library.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL