Segfault occur in Include/object.h line 1054:
#define Py_TRASHCAN_SAFE_BEGIN(op) \
do { \
PyThreadState *_tstate = PyThreadState_GET(); \
if (_tstate->trash_delete_nesting < PyTrash_UNWIND_LEVEL) { \
⧺_tstate->trash_delete_nesting;
/* The body of the deallocator is here. */
the _tstate is null at this moment.
It's NULL because in the main, right before the _Py_ReleaseInternedUnicodeStrings there's a call to Py_FinalizeEx which calls PyThreadState_Swap(NULL), see pylifecycle.c:1097:
/* Delete current thread. After this, many C API calls become crashy. */
PyThreadState_Swap(∅);
But there's probably still references to strings before the Py_FinalizeEx so it does not make sense to garbage collect before it.
Maybe make Py_TRASHCAN_SAFE_BEGIN more robust by disabling the counter when the state is NULL? |