[issue39778] collections.OrderedDict and weakref.ref raises "refcount is too small" assertion

Tim Peters report at bugs.python.org
Thu Feb 27 22:38:48 EST 2020


Tim Peters <tim at python.org> added the comment:

Thanks for the succinct example!  Although you don't need the print() ;-)

I can confirm this crashes the same way under a current master build (albeit on Windows 64-bit).

gc is calculating how many references in the current generation are accounted for by intra-generation references, and gc's visit_decref() is getting called back by odictobject.c's odict_traverse(), on line

    Py_VISIT(od->od_weakreflist);

gc has found a second pointer to od->od_weakreflist, which is more than its refcount (1) claims exist.

Python's weakref implementation gives me headaches, so I'm adding Raymond to the nosy list under the hope the problem will be obvious to him.

----------
components: +Extension Modules -C API
nosy: +rhettinger, tim.peters
stage:  -> needs patch
versions: +Python 3.7, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39778>
_______________________________________


More information about the Python-bugs-list mailing list