]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-122697: Fix free-threading memory leaks at shutdown (#122703)
authorSam Gross <colesbury@gmail.com>
Thu, 8 Aug 2024 16:48:17 +0000 (12:48 -0400)
committerGitHub <noreply@github.com>
Thu, 8 Aug 2024 16:48:17 +0000 (12:48 -0400)
commit2d9d3a9f5319ce3f850341d116b63cc51869df3a
tree6d5250d1af82d114d310655fe164c932b955ea4b
parent833eb106f5ebbac258f236d50177712d98a36715
gh-122697: Fix free-threading memory leaks at shutdown (#122703)

We were not properly accounting for interpreter memory leaks at
shutdown and had two sources of leaks:

 * Objects that use deferred reference counting and were reachable via
   static types outlive the final GC. We now disable deferred reference
   counting on all objects if we are calling the GC due to interpreter
   shutdown.

 * `_PyMem_FreeDelayed` did not properly check for interpreter shutdown
   so we had some memory blocks that were enqueued to be freed, but
   never actually freed.

 * `_PyType_FinalizeIdPool` wasn't called at interpreter shutdown.
Misc/NEWS.d/next/Core_and_Builtins/2024-08-05-19-28-12.gh-issue-122697.17MvYl.rst [new file with mode: 0644]
Objects/obmalloc.c
Python/gc_free_threading.c
Python/pylifecycle.c
Python/pystate.c