Yury Selivanov <[email protected]> added the comment:
This isn't a real reference bug, but rather a bug in total refs accountability.
It seems that I missed the fact that we track refs to the keys table with a
DK_INCREF macro.
The new `clone_combined_dict` uses `memcpy` to clone the keys table (along with
its `dk_refcnt` field, but it doesn't register the fact that we have a new keys
table after copying. The bug can be solved with the following diff:
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 7a1bcebec6..3ac6a54415 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -656,6 +656,7 @@ clone_combined_dict(PyDictObject *orig)
/* Maintain tracking. */
_PyObject_GC_TRACK(new);
}
+ _Py_INC_REFTOTAL;
return (PyObject *)new;
}
I don't think this is a critical-level bug that needs an emergency 3.7.1
release, but I'll submit a PR right now. Would appreciate if you guys can
review it.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34042>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com