New submission from Leonard Lausen <leon...@lausen.nl>:
Below sample program, will raise "Modules/gcmodule.c:110: gc_decref: Assertion "gc_get_refs(g) > 0" failed: refcount is too small" on Python 3.8.2 debug build. On 3.7.6 debug build, "Modules/gcmodule.c:277: visit_decref: Assertion `_PyGCHead_REFS(gc) != 0' failed." is raised. ``` import collections import gc import weakref hooks_dict = collections.OrderedDict() hooks_dict_ref = weakref.ref(hooks_dict) gc.collect() print('Hello world') ``` The complete error message on 3.8.2 debug build is ``` Modules/gcmodule.c:110: gc_decref: Assertion "gc_get_refs(g) > 0" failed: refcount is too small Memory block allocated at (most recent call first): File "/home/$USER/test.py", line 6 object : <weakref at 0x7ff788208a70; to 'collections.OrderedDict' at 0x7ff7881fab90> type : weakref refcount: 1 address : 0x7ff788208a70 Fatal Python error: _PyObject_AssertFailed Python runtime state: initialized Current thread 0x00007ff789f9c080 (most recent call first): File "/home/$USER/test.py", line 7 in <module> zsh: abort PYTHONTRACEMALLOC=1 python ~/test.py ``` ---------- components: C API messages: 362846 nosy: leezu priority: normal severity: normal status: open title: collections.OrderedDict and weakref.ref raises "refcount is too small" assertion versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39778> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com