Skip to content

PyUnstable_GC_VisitObjects should traverse the permanent generation as well #131740

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

Closed
martindemello opened this issue Mar 25, 2025 · 2 comments
Closed
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-bug An unexpected behavior, bug, or error

Comments

@martindemello
Copy link
Contributor

martindemello commented Mar 25, 2025

Bug report

Bug description:

This function is meant to walk the heap and visit all GCable objects. It currently ignores the permanent / frozen generation, which is a problem when calling code expects to get all extant objects.

As a concrete example, the cinder JIT compiler uses this function to scan through all Python functions on the heap and try JIT compiling them. Functions that have been frozen by gc.freeze() or immortalize_heap() are not processed, and thus do not get compiled.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

@corona10
Copy link
Member

corona10 commented Mar 25, 2025

The API was originally introduced for a use case from Cinder, so we may need to check whether it was intended.
@mpage Do you have any opinions about it?

ref: #102013

@martindemello
Copy link
Contributor Author

@corona10 I work on cinder too; the current implementation is causing us some issues, so I figured we would add the fix upstream first and then backport it. thanks for doing the fix already :)

@corona10 corona10 self-assigned this Mar 26, 2025
corona10 added a commit to corona10/cpython that referenced this issue Mar 26, 2025
corona10 added a commit that referenced this issue Mar 26, 2025
gh-131754)

* [3.13] gh-131740: Update PyUnstable_GC_VisitObjects to traverse perm gen (gh-131744)

(cherry picked from commit 7bb41ae)

* fix
corona10 added a commit to corona10/cpython that referenced this issue Mar 28, 2025
corona10 added a commit to corona10/cpython that referenced this issue Mar 28, 2025
corona10 added a commit to corona10/cpython that referenced this issue Mar 28, 2025
@picnixz picnixz added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Mar 28, 2025
corona10 pushed a commit that referenced this issue Mar 28, 2025
…1786)

Minor readability fix in PyUnstable_GC_VisitObjects

Replaces `if (visit_generation())` with `if (visit_generation() < 0)`,
since we are checking for the failure case, and it's confusing to have
that be implicitly `true`.

Also fixes a misspelt variable name.
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
…ythongh-131786)

Minor readability fix in PyUnstable_GC_VisitObjects

Replaces `if (visit_generation())` with `if (visit_generation() < 0)`,
since we are checking for the failure case, and it's confusing to have
that be implicitly `true`.

Also fixes a misspelt variable name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants