aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-08 01:22:36 +0200
committerGitHub <noreply@github.com>2020-06-08 01:22:36 +0200
commit7907f8cbc6923240edb0b5b63adafb871c4c8875 (patch)
treecf7b25467780c2bd7e899bfc477f73625930718c /Python/pylifecycle.c
parentbpo-39791: Support file systems that cannot support non-ascii filenames (skip... (diff)
downloadcpython-7907f8cbc6923240edb0b5b63adafb871c4c8875.tar.gz
cpython-7907f8cbc6923240edb0b5b63adafb871c4c8875.tar.bz2
cpython-7907f8cbc6923240edb0b5b63adafb871c4c8875.zip
bpo-40887: Fix finalize_interp_clear() for free lists (GH-20698)
Reorganize code to ensure that free lists are cleared in the right order. Call _PyWarnings_Fini() before _PyList_Fini().
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 6d2eb1defc8..d730a98d3e5 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1250,37 +1250,26 @@ static void
finalize_interp_types(PyThreadState *tstate, int is_main_interp)
{
_PyFrame_Fini(tstate);
- _PyTuple_Fini(tstate);
- _PyList_Fini(tstate);
+ _PyAsyncGen_Fini(tstate);
+ _PyContext_Fini(tstate);
+
if (is_main_interp) {
_PySet_Fini();
- _PyBytes_Fini();
}
-
- _PyLong_Fini(tstate);
- _PyFloat_Fini(tstate);
-
if (is_main_interp) {
_PyDict_Fini();
}
+ _PyList_Fini(tstate);
+ _PyTuple_Fini(tstate);
_PySlice_Fini(tstate);
- _PyWarnings_Fini(tstate->interp);
if (is_main_interp) {
- _Py_HashRandomization_Fini();
- _PyArg_Fini();
+ _PyBytes_Fini();
}
-
- _PyAsyncGen_Fini(tstate);
- _PyContext_Fini(tstate);
-
- /* Cleanup Unicode implementation */
_PyUnicode_Fini(tstate);
-
- if (is_main_interp) {
- _Py_ClearFileSystemEncoding();
- }
+ _PyFloat_Fini(tstate);
+ _PyLong_Fini(tstate);
}
@@ -1299,19 +1288,20 @@ finalize_interp_clear(PyThreadState *tstate)
_PyGC_Fini(tstate);
- finalize_interp_types(tstate, is_main_interp);
-
if (is_main_interp) {
- /* XXX Still allocated:
- - various static ad-hoc pointers to interned strings
- - int and float free list blocks
- - whatever various modules and libraries allocate
- */
+ _Py_HashRandomization_Fini();
+ _PyArg_Fini();
+ _Py_ClearFileSystemEncoding();
+ }
- PyGrammar_RemoveAccelerators(&_PyParser_Grammar);
+ _PyWarnings_Fini(tstate->interp);
+ if (is_main_interp) {
+ PyGrammar_RemoveAccelerators(&_PyParser_Grammar);
_PyExc_Fini();
}
+
+ finalize_interp_types(tstate, is_main_interp);
}