Bug report
Bug description:
The HAMT iterator types declare Py_TPFLAGS_HAVE_GC and implement tp_traverse, tp_clear and a tp_dealloc that untracks, but hamt_baseiter_new() never called PyObject_GC_Track(). A reference cycle running through an iterator -- iterator -> HAMT -> object -> iterator -- was therefore invisible to the collector and never freed. Because a contextvars.Context is backed by a HAMT that pins every object in it, one leaked iterator leaks the whole context.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
The HAMT iterator types declare
Py_TPFLAGS_HAVE_GCand implement tp_traverse, tp_clear and a tp_dealloc that untracks, buthamt_baseiter_new()never calledPyObject_GC_Track(). A reference cycle running through an iterator -- iterator -> HAMT -> object -> iterator -- was therefore invisible to the collector and never freed. Because acontextvars.Contextis backed by a HAMT that pins every object in it, one leaked iterator leaks the whole context.CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs