3.12: Py_FinalizeEx: the function must be called with the GIL held (_PyObject_DebugMallocStats) #107848
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-bug
An unexpected behavior, bug, or error
I am embedding Python 3.12.0rc1 in a C++ application on Windows.
With the interpreter compiled in DEBUG mode and running a debugging session with MSVC, I get the following error message right before reaching a breakpoint:
Fatal Python error: the function must be called with the GIL held, after Python initialization and before Python finalization, but the GIL is released (the current Python thread state is NULL)
The breakpoint is reached with the following call stack:
My application configures the interpreter in so-called isolated mode and with the flag
PyConfig.malloc_stats
set to1
(among other ones).However if I set
malloc_stats
to0
, the breakpoint is never reached, the interpreter finalizes gracefully and the application terminates with no issue.To narrow down the issue, I removed all the code between Python initialization and finalization. No builtin module is registered by the application itself, and it does not run nor import any Python module.
This issue might be related to #105690?
Please let me know if any extra information is required!
The text was updated successfully, but these errors were encountered: