]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38962: Fix reference leak in the per-subinterpreter gc (GH-17457)
authorPablo Galindo <Pablogsal@gmail.com>
Wed, 4 Dec 2019 11:51:03 +0000 (11:51 +0000)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 4 Dec 2019 11:51:03 +0000 (03:51 -0800)
https://bugs.python.org/issue38962

Automerge-Triggered-By: @pablogsal
Python/pylifecycle.c

index 9218978cc6fa7d545c80534d005ce8c5dabeec8f..d6f65ec3caf66e00146e2ec1366ea5a99f2bf151 100644 (file)
@@ -1253,17 +1253,16 @@ finalize_interp_clear(PyThreadState *tstate)
 {
     int is_main_interp = _Py_IsMainInterpreter(tstate);
 
-    /* bpo-36854: Explicitly clear the codec registry
-       and trigger a GC collection */
     PyInterpreterState *interp = tstate->interp;
-    Py_CLEAR(interp->codec_search_path);
-    Py_CLEAR(interp->codec_search_cache);
-    Py_CLEAR(interp->codec_error_registry);
-    _PyGC_CollectNoFail();
 
     /* Clear interpreter state and all thread states */
     PyInterpreterState_Clear(tstate->interp);
 
+    /* Trigger a GC collection on subinterpreters*/
+    if (!is_main_interp) {
+        _PyGC_CollectNoFail();
+    }
+
     finalize_interp_types(tstate, is_main_interp);
 
     if (is_main_interp) {