mirror of
https://github.com/python/cpython.git
synced 2025-12-31 12:33:28 +00:00
[3.14] gh-142975: During GC, mark frozen objects with a merged zero refcount for destruction (GH-143156) (GH-143175)
gh-142975: During GC, mark frozen objects with a merged zero refcount for destruction (GH-143156)
(cherry picked from commit 8611f74e08)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
parent
02282e5479
commit
8a61b71eee
3 changed files with 39 additions and 1 deletions
|
|
@ -905,7 +905,11 @@ gc_visit_thread_stacks_mark_alive(PyInterpreterState *interp, gc_mark_args_t *ar
|
|||
static void
|
||||
queue_untracked_obj_decref(PyObject *op, struct collection_state *state)
|
||||
{
|
||||
if (!_PyObject_GC_IS_TRACKED(op)) {
|
||||
assert(Py_REFCNT(op) == 0);
|
||||
// gh-142975: We have to treat frozen objects as untracked in this function
|
||||
// or else they might be picked up in a future collection, which breaks the
|
||||
// assumption that all incoming objects have a non-zero reference count.
|
||||
if (!_PyObject_GC_IS_TRACKED(op) || gc_is_frozen(op)) {
|
||||
// GC objects with zero refcount are handled subsequently by the
|
||||
// GC as if they were cyclic trash, but we have to handle dead
|
||||
// non-GC objects here. Add one to the refcount so that we can
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue