Skip to content

Memory leak with static iterator types #91632

Closed

Description

@kumaraditya303

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

Activity

  1. corona10 commented on Apr 17, 2022

    @corona10
    Member
  2. vstinner commented on Apr 19, 2022

    @vstinner
    Member

    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.

  3. self-assigned this
    on Apr 20, 2022
  4. added a commit that references this issue on Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.11only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-C-API

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions