Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Crash report
What happened?
(Found while investigating a fix for#125920.)
Subinterpreters that are running in a different thread can still be running upon the finalization of the main interpreter, depending on what the thread was doing. Take the following script:
fromthreadingimportThreadimport_interpretersdefsilly():interp=_interpreters.create()_interpreters.run_string(interp,"import time; time.sleep(100)")if__name__=="__main__":Thread(target=silly).start()
On 3.13 and 3.14, killing the process with CTRL+C results in an assertion failure:
python: Python/pylifecycle.c:2480: finalize_subinterpreters: Assertion `!_PyInterpreterState_IsRunningMain(interp)' failed.However, if the thread is daemon, then the interpreter fully segfaults:
fromthreadingimportThreadimport_interpretersdefsilly():interp=_interpreters.create()_interpreters.run_string(interp,"import time; time.sleep(100)")if__name__=="__main__":Thread(target=silly,daemon=True).start()
I'm going to investigate possible fixes.
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
No response
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done