Bug report
Bug description:
I noticed that tearing down a subinterpreter's thread state aborts on an assertion.
python: Objects/obmalloc.c:215: _PyMem_mi_page_reclaimed: Assertion `tstate == (_PyThreadStateImpl *)_PyThreadState_GET()' failed.
fish: Job 1, './python xxxxx' terminated by signal SIGABRT (Abort)
This can be easily reproduced on a free-threaded debug build by running:
import _testinternalcapi
interpid = _testinternalcapi.create_interpreter()
_testinternalcapi.destroy_interpreter(interpid, basic=True)
Some Investigation
This assertion was added in #145626 . Interestingly, the author @colesbury said in the PR:
In _PyMem_mi_page_maybe_free(), use the page's heap tld to find the correct thread state ...... so the current thread state is not necessarily the owner of the page.
Since _PyMem_mi_page_maybe_free() doesn't assume the page owner to be current thread, maybe that's the same for _PyMem_mi_page_reclaimed ?
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Bug report
Bug description:
I noticed that tearing down a subinterpreter's thread state aborts on an assertion.
This can be easily reproduced on a free-threaded debug build by running:
Some Investigation
This assertion was added in #145626 . Interestingly, the author @colesbury said in the PR:
Since
_PyMem_mi_page_maybe_free()doesn't assume the page owner to be current thread, maybe that's the same for_PyMem_mi_page_reclaimed?CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux