Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
Crash report
What happened?
fromconcurrent.futuresimportInterpreterPoolExecutorexecutor=InterpreterPoolExecutor()deff():import_datetimeprint(_datetime)executor.submit(f)executor.submit(f)executor.shutdown()
This codemay lead to a interpreter crash:
PS C:\Users\xxx\Source\cpython> .\python.bat .\a.pyRunning Debug|x64 interpreter...<module '_datetime' (built-in)> # The first sub-interpreter's outputAssertion failed: !managed_static_type_index_is_set(self), file C:\Users\xxxxx\Source\cpython\Objects\typeobject.c, line 317Please note that there is a similar issue may crash the interpreter but in the sestructing phase:#136423
My analyze
The_datetime module will call_PyStaticType_InitForExtension to initialize some static types. Look at it's implementation:
Lines 9269 to 9273 in490eea0
| int | |
| _PyStaticType_InitForExtension(PyInterpreterState*interp,PyTypeObject*self) | |
| { | |
| returninit_static_type(interp,self,0, ((self->tp_flags&Py_TPFLAGS_READY)==0)); | |
| } |
It's usingtp_flagsPy_TPFLAGS_READY to determine if this type is already initialized. And at last it will callmanaged_static_type_state_init with the initialized flag.
If the type flagPy_TPFLAGS_READY was not set before, and another sub-interpreter has been initialized, finished, and has set thePy_TPFLAGS_READY flag, this assertion will be triggered:
Lines 316 to 317 in490eea0
| if (initial) { | |
| assert(!managed_static_type_index_is_set(self)); |
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS, Windows
Output from running 'python -VV' on the command line:
Python 3.15.0a0 (heads/main:ba9c1986305, Jul 8 2025, 22:13:18) [MSC v.1943 64 bit (AMD64)]
Linked PRs
- gh-136421: Fix crash when _datetime is been initialized in multiple sub-interpreters #136422
- gh-136421: Load
_datetimestatic types during interpreter initialization #136583 - gh-136421: Fix crash in _datetime when initialized/finalized concurrently #136620
- [3.14] gh-136421: Load
_datetimestatic types during interpreter initialization (GH-136583) #136943
Metadata
Metadata
Assignees
Labels
Projects
Status
Status