Skip to content

gh-137110: Untrack immortal objects from expand_region_transitivity_reachable #137111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sergey-miryanov
Copy link
Contributor

@sergey-miryanov sergey-miryanov commented Jul 25, 2025

There is some inconsistency in handling of immortal objects in default-build's GC.

In update_refs immortal objects just untracked (all immortal objects that we face in GC is an accidentally immortalized).

cpython/Python/gc.c

Lines 495 to 500 in 1e69cd1

if (_Py_IsImmortal(op)) {
assert(!_Py_IsStaticImmortal(op));
_PyObject_GC_UNTRACK(op);
gc = next;
continue;
}

update_refs called for all collections (young, increment and full). But for incremental collection if increment_size < gcstate->work_to_do we steal some objects from neighbor gen and call expand_region_transitively_reachable where immortal objects moved to permanent generation:

cpython/Python/gc.c

Lines 1397 to 1402 in 1e69cd1

if (_Py_IsImmortal(op)) {
PyGC_Head *next = GC_NEXT(gc);
gc_list_move(gc, &gcstate->permanent_generation.head);
gc = next;
continue;
}

So, one part of immortal objects can be untracked, and other part can be moved to perm gen.

As I understand from #127519 it is preferring to untrack immortal objects in all cases.

CPython versions tested on:

CPython main branch

@sergey-miryanov
Copy link
Contributor Author

I'm not sure, but this probably should skip news.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy