Skip to content
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

Memory leak with static iterator types #91632

Closed
kumaraditya303 opened this issue Apr 17, 2022 · 2 comments · Fixed by #91727
Closed

Memory leak with static iterator types #91632

kumaraditya303 opened this issue Apr 17, 2022 · 2 comments · Fixed by #91727
Assignees
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API

Comments

@kumaraditya303
Copy link
Contributor

kumaraditya303 commented Apr 17, 2022

Python does not finalizes iterators of some types at exit leading to memory leak.

Reproducer:

a = type(iter(tuple[int]))
print(a.mro())

Leak:

[<class 'generic_alias_iterator'>, <class 'object'>]
[119 refs, 46 blocks]

See also #90575

@kumaraditya303 kumaraditya303 added interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.11 only security fixes topic-C-API labels Apr 17, 2022
@corona10
Copy link
Member

cc @vstinner

@vstinner
Copy link
Member

vstinner commented Apr 19, 2022

static PyTypeObject Py_GenericAliasIterType = {...} of Objects/genericaliasobject.c is not cleared at exit. It's a variant of https://bugs.python.org/issue46417

Either the type should be accessible in Objects/object.c for _PyTypes_FiniTypes() (remove "static", add "_" to hide the symbol). Or a _PyGenericAlias_Fini() function should be added in called in finalize_interp_types() in the main interpreter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants