]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-125859: Fix crash when `gc.get_objects` is called during GC (GH-125882...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 24 Oct 2024 14:08:15 +0000 (16:08 +0200)
committerGitHub <noreply@github.com>
Thu, 24 Oct 2024 14:08:15 +0000 (14:08 +0000)
commit5c2696bc261905b84c71ddbee3f439af568a8795
tree761f299ab0ec18c47d5751e5d4e3d6a0c0c6ad3b
parente334022de0adef5bbf1f59c5226ca521dcfed4aa
[3.13] gh-125859: Fix crash when `gc.get_objects` is called during GC (GH-125882) (GH-125921)

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.
(cherry picked from commit e545ead66ce725aae6fb0ad5d733abe806c19750)

Co-authored-by: Sam Gross <colesbury@gmail.com>
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