[issue39877] Daemon thread is crashing in PyEval_RestoreThread() while the main thread is exiting the process

STINNER Victor report at bugs.python.org
Fri Mar 6 09:53:16 EST 2020


STINNER Victor <vstinner at python.org> added the comment:

Patch to get a cleaner error if the bug occurs, but also to make the bug more reliable:

diff --git a/Python/ceval.c b/Python/ceval.c
index ef4aac2f9a..8bf1e4766d 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -382,7 +382,8 @@ PyEval_SaveThread(void)
 void
 PyEval_RestoreThread(PyThreadState *tstate)
 {
-    assert(tstate != NULL);
+    assert(!_PyMem_IsPtrFreed(tstate));
+    assert(!_PyMem_IsPtrFreed(tstate->interp));
 
     _PyRuntimeState *runtime = tstate->interp->runtime;
     struct _ceval_runtime_state *ceval = &runtime->ceval;

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39877>
_______________________________________


More information about the Python-bugs-list mailing list