]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-125859: Fix crash when `gc.get_objects` is called during GC (#125882)
authorSam Gross <colesbury@gmail.com>
Thu, 24 Oct 2024 13:33:11 +0000 (09:33 -0400)
committerGitHub <noreply@github.com>
Thu, 24 Oct 2024 13:33:11 +0000 (09:33 -0400)
commite545ead66ce725aae6fb0ad5d733abe806c19750
tree00c0125dc1c8929c76ad5d1e1100136cfa6591a9
parentb61fece8523d0fa6d9cc6ad3fd855a136c34f0cd
gh-125859: Fix crash when `gc.get_objects` is called during GC (#125882)

This fixes a crash when `gc.get_objects()` or `gc.get_referrers()` is
called during a GC in the free threading build.

Switch to `_PyObjectStack` to avoid corrupting the `struct worklist`
linked list maintained by the GC. Also, don't return objects that are frozen
(`gc.freeze()`) or in the process of being collected to more closely match
the behavior of the default build.
Include/internal/pycore_object_stack.h
Lib/test/test_free_threading/test_gc.py [new file with mode: 0644]
Lib/test/test_gc.py
Misc/NEWS.d/next/Core_and_Builtins/2024-10-23-14-42-27.gh-issue-125859.m3EF9E.rst [new file with mode: 0644]
Python/gc_free_threading.c