[Python-Dev] Valgrind on 2.2.2 (original) (raw)

Guido van Rossum guido@python.org
Thu, 17 Oct 2002 20:51:17 -0400


There are also a few fingers pointing in the direction of weakrefref, e.g.

==28827== 520 bytes in 14 blocks are possibly lost in loss record 48 of 106 ==28827== at 0x400481B4: malloc (vgclientfuncs.c:100) ==28827== by 0x8099519: PyObjectGCNew (Modules/gcmodule.c:868) ==28827== by 0x8067BA5: PyWeakrefNewRef (Objects/weakrefobject.c:37) ==28827== by 0x8066119: addsubclass (Objects/typeobject.c:2249) ==28827== by 0x8061F29: PyTypeReady (Objects/typeobject.c:2219) ==28827== by 0x80605A8: typenew (Objects/typeobject.c:1280) ==28827== by 0x805EDA4: typecall (Objects/typeobject.c:183) ==28827== by 0x80ABB0C: PyObjectCall (Objects/abstract.c:1688) ==28827== by 0x807A34F: PyEvalCallObjectWithKeywords (Python/ceval.c:3058) ==28827== by 0x80AB0C6: PyObjectCallFunction (Objects/abstract.c:1679) Of course many of these could be caused by a single leak that drops a pointer to a container -- then everything owned by that container is also leaked.

This one seems simple:

diff -c -c -r2.126.4.25 typeobject.c *** typeobject.c 11 Oct 2002 00:22:22 -0000 2.126.4.25 --- typeobject.c 18 Oct 2002 00:50:31 -0000


*** 2249,2256 **** while (--i >= 0) { ref = PyList_GET_ITEM(list, i); assert(PyWeakref_CheckRef(ref)); ! if (PyWeakref_GET_OBJECT(ref) == Py_None) ! return PyList_SetItem(list, i, new); } i = PyList_Append(list, new); Py_DECREF(new); --- 2249,2259 ---- while (--i >= 0) { ref = PyList_GET_ITEM(list, i); assert(PyWeakref_CheckRef(ref)); ! if (PyWeakref_GET_OBJECT(ref) == Py_None) { ! i = PyList_SetItem(list, i, new); ! Py_DECREF(new); ! return i; ! } } i = PyList_Append(list, new); Py_DECREF(new);

--Guido van Rossum (home page: http://www.python.org/~guido/)