diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-07 13:50:49 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-07 13:50:49 (GMT) |
commit | 51fa458d0a8fa6e9f583fc5a1c4164080093e763 (patch) | |
tree | fb94407a2596b2c19acff6913ff8e7d711fbbc6c /Python | |
parent | b385529ddfcd5e46890438dc32c6dba341e039b0 (diff) | |
download | cpython-51fa458d0a8fa6e9f583fc5a1c4164080093e763.zip cpython-51fa458d0a8fa6e9f583fc5a1c4164080093e763.tar.gz cpython-51fa458d0a8fa6e9f583fc5a1c4164080093e763.tar.bz2 |
Issue #18203: Fix Py_Finalize(): destroy the GIL after the last call to
PyMem_Malloc() or PyObject_Malloc().
For example, PyCFunction_Fini() calls PyObject_GC_Del() which calls
PyObject_FREE().
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pythonrun.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 02a4329..94175be 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -606,11 +606,6 @@ Py_Finalize(void) _PyExc_Fini(); - /* Cleanup auto-thread-state */ -#ifdef WITH_THREAD - _PyGILState_Fini(); -#endif /* WITH_THREAD */ - /* Sundry finalizers */ PyMethod_Fini(); PyFrame_Fini(); @@ -629,10 +624,6 @@ Py_Finalize(void) /* Cleanup Unicode implementation */ _PyUnicode_Fini(); - /* Delete current thread. After this, many C API calls become crashy. */ - PyThreadState_Swap(NULL); - PyInterpreterState_Delete(interp); - /* reset file system default encoding */ if (!Py_HasFileSystemDefaultEncoding && Py_FileSystemDefaultEncoding) { free((char*)Py_FileSystemDefaultEncoding); @@ -647,6 +638,15 @@ Py_Finalize(void) PyGrammar_RemoveAccelerators(&_PyParser_Grammar); + /* Cleanup auto-thread-state */ +#ifdef WITH_THREAD + _PyGILState_Fini(); +#endif /* WITH_THREAD */ + + /* Delete current thread. After this, many C API calls become crashy. */ + PyThreadState_Swap(NULL); + PyInterpreterState_Delete(interp); + #ifdef Py_TRACE_REFS /* Display addresses (& refcnts) of all objects still alive. * An address can be used to find the repr of the object, printed |