-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
The following crashes in a debug build of Python:
import gc
import pycld2
gc.collect()Modules/gcmodule.c:114: gc_decref: Assertion "gc_get_refs(g) > 0" failed: refcount is too small
Enable tracemalloc to get the memory block allocation traceback
object address : 0x555555a2bf70
object refcount : 4
object type : 0x555555966400
object type name: type
object repr : <class 'pycld2.error'>
Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Python runtime state: initialized
Current thread 0x00007ffff7c33280 (most recent call first):
File "<string>", line 1 in <module>
Aborted (core dumped)
The problem is that the module initialization creates two references tracked by the garbage collector, but one of them is missing a Py_INCREF. (The garbage collector works by subtracting incoming references from the reference count. In this case, the reference count is too small.)
pycld2/bindings/pycldmodule.cc
Line 393 in d631950
| st->error = PyErr_NewException("pycld2.error", NULL, NULL); |
pycld2/bindings/pycldmodule.cc
Lines 644 to 645 in d631950
| // Steals ref: | |
| PyModule_AddObject(m, "error", st->error); |
Metadata
Metadata
Assignees
Labels
No labels