diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-06-17 02:39:18 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-06-17 02:39:18 (GMT) |
commit | c0bc4eff5093bd4268cb3d02b9dca2fcbe7e59ca (patch) | |
tree | 9a2ee96173bee1404d002fe5e53c86fd6d2193aa /Python/ceval.c | |
parent | 1a6561e2f593143565a6562e7818ea735d2b6790 (diff) | |
download | cpython-c0bc4eff5093bd4268cb3d02b9dca2fcbe7e59ca.zip cpython-c0bc4eff5093bd4268cb3d02b9dca2fcbe7e59ca.tar.gz cpython-c0bc4eff5093bd4268cb3d02b9dca2fcbe7e59ca.tar.bz2 |
avoid crashes and lockups from daemon threads during interpreter shutdown (#1856)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 18bc66b..b1f5e8e 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -355,6 +355,12 @@ PyEval_RestoreThread(PyThreadState *tstate) if (interpreter_lock) { int err = errno; PyThread_acquire_lock(interpreter_lock, 1); + /* _Py_Finalizing is protected by the GIL */ + if (_Py_Finalizing && tstate != _Py_Finalizing) { + PyThread_release_lock(interpreter_lock); + PyThread_exit_thread(); + assert(0); /* unreachable */ + } errno = err; } #endif |