This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author stestagg
Recipients CendioOssman, stestagg
Date 2020-12-06.23:01:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1607295671.14.0.0621001572983.issue42540@roundup.psfhosted.org>
In-reply-to
Content
So, I'm not an allocator/init/teardown expert, but it looks like: When you fork, PyRuntimeState creates a new mutex, explicitly using the default allocator (without the debug allocator active).. #ifdef HAVE_FORK /* This function is called from PyOS_AfterFork_Child to ensure that newly created child processes do not share locks with the parent. */ PyStatus _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime) { // This was initially set in _PyRuntimeState_Init(). runtime->main_thread = PyThread_get_thread_ident(); /* Force default allocator, since _PyRuntimeState_Fini() must use the same allocator than this function. */ PyMemAllocatorEx old_alloc; _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc); int reinit_interp = _PyThread_at_fork_reinit(&runtime->interpreters.mutex); int reinit_main_id = _PyThread_at_fork_reinit(&runtime->interpreters.main->id_mutex); int reinit_xidregistry = _PyThread_at_fork_reinit(&runtime->xidregistry.mutex); PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc); if (reinit_interp < 0 || reinit_main_id < 0 || reinit_xidregistry < 0) { return _PyStatus_ERR("Failed to reinitialize runtime locks"); } return _PyStatus_OK(); } #endif But the PyInterpreterState_Delete function does not do this: if (interp->id_mutex != NULL) { PyThread_free_lock(interp->id_mutex); } Which causes it to try to use the debug allocator to free, and hence crash..
History
Date User Action Args
2020-12-06 23:01:11stestaggsetrecipients: + stestagg, CendioOssman
2020-12-06 23:01:11stestaggsetmessageid: <1607295671.14.0.0621001572983.issue42540@roundup.psfhosted.org>
2020-12-06 23:01:11stestagglinkissue42540 messages
2020-12-06 23:01:10stestaggcreate