Legacy-mode subinterpreters in Python 3.12: import _tkinter
leads to shutdown crash
#115649
Labels
import _tkinter
leads to shutdown crash
#115649
Bug report
Bug description:
Hello everyone,
I am working on an application embedding multiple Python subinterpreters - for which the Python version should be upgraded from Python 3.10 to Python 3.12.1. For the time being, the "legacy version" of subinterpreters (i.e., using a global, shared GIL) should be used, since all Python extensions (including
_tkinter
and all extensions with single-phase initialization) should be supported.If I understand the docs correctly, using the legacy
Py_NewInterpreter()
method should preserve the existing behavior. Still, the following application crashes at shutdown:When compiling and running this program with a debug build of Python 3.12.1 (or later) on Linux, I get this output:
With a non-debug build, the program exits with a segmentation fault.
The
gdb
backtrace looks as follows:Digging further into the backtrace, it looks like the Python garbage collector is trying to decrease the reference counter to the
_tkinter
module twice, despite it having been increased only once. Oddly enough, the program runs just fine when destroying the interpreters in reverse order:Can anyone help me shed some light into this issue? Is there anything I am overlooking?
CPython versions tested on:
3.12.1, 3.12.2, 3.13.0a4
Operating systems tested on:
Linux, Windows
Tasks
The text was updated successfully, but these errors were encountered: