[Python-Dev] Memory leaks in tupleobject.c

Charles G Waldman cgw@fnal.gov
Thu, 14 Dec 2000 00:03:01 -0600 (CST)


I've been running a set of memory-leak tests against the latest Python
and have found that running "test_extcall" leaks memory.  This gave me
a strange sense of deja vu, having fixed this once before...

>From the CVS logs for tupleobject.c:

 revision 2.31
 date: 2000/04/21 21:15:05;  author: guido;  state: Exp;  lines: +59 -16
 Patch by Charles G Waldman to avoid a sneaky memory leak in
 _PyTuple_Resize(). 

 revision 2.47
 date: 2000/10/05 19:36:49;  author: nascheme;  state: Exp;  lines: +24 -86
 Simplify _PyTuple_Resize by not using the tuple free list and dropping
 support for the last_is_sticky flag.  A few hard to find bugs may be
 fixed by this patch since the old code was buggy.

The 2.47 patch seems to have re-introduced the memory leak which was
fixed in 2.31.  Maybe the old code was buggy, but the "right thing"
would have been to fix it, not to throw it away.... if _PyTuple_Resize
simply ignores the tuple free list, memory will be leaked.