[Python-checkins] cpython (merge 3.3 -> default): Fix crash caused by 8c1385205a35

antoine.pitrou python-checkins at python.org
Sun May 5 08:16:21 CEST 2013


http://hg.python.org/cpython/rev/6f4627a65c0a
changeset:   83624:6f4627a65c0a
parent:      83622:bf325cd5cc94
parent:      83623:7de9852cdc0e
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sun May 05 08:14:53 2013 +0200
summary:
  Fix crash caused by 8c1385205a35
(thanks Arfrever for reporting).

files:
  Python/pythonrun.c |  14 ++++++++------
  1 files changed, 8 insertions(+), 6 deletions(-)


diff --git a/Python/pythonrun.c b/Python/pythonrun.c
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -576,6 +576,9 @@
     /* Destroy the database used by _PyImport_{Fixup,Find}Extension */
     _PyImport_Fini();
 
+    /* Cleanup typeobject.c's internal caches. */
+    _PyType_Fini();
+
     /* unload faulthandler module */
     _PyFaulthandler_Fini();
 
@@ -596,7 +599,7 @@
         _Py_PrintReferences(stderr);
 #endif /* Py_TRACE_REFS */
 
-    /* Clear interpreter state */
+    /* Clear interpreter state and all thread states. */
     PyInterpreterState_Clear(interp);
 
     /* Now we decref the exception classes.  After this point nothing
@@ -612,10 +615,6 @@
     _PyGILState_Fini();
 #endif /* WITH_THREAD */
 
-    /* Delete current thread */
-    PyThreadState_Swap(NULL);
-    PyInterpreterState_Delete(interp);
-
     /* Sundry finalizers */
     PyMethod_Fini();
     PyFrame_Fini();
@@ -629,11 +628,14 @@
     PyFloat_Fini();
     PyDict_Fini();
     PySlice_Fini();
-    _PyType_Fini();
 
     /* 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);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list