[Numpy-discussion] fromfile (binary) double free or corruption

Scott Ransom sransom@nrao....
Sun Mar 2 09:27:46 CST 2008


Hi All,

So I've just come upon a new(ish?) bug in fromfile.  I'm running
numpy from subversion rev 4839.

Seems that if you try to read a number of items from a binary file
but none are read (i.e. you are already at the EOF), you get the
following:

4096 items requested but only 0 read
*** glibc detected *** python: double free or corruption (!prev):
0x00000000009f5340 ***

and the code needs to be killed.

I ran my code under gdb and got the following traceback (just
keeping the important lines):

#14 0x00002ae639f8b34b in backtrace () from /lib/libc.so.6
#15 0x00002ae639f1ff9f in ?? () from /lib/libc.so.6
#16 0x00002ae639f2505d in ?? () from /lib/libc.so.6
#17 0x00002ae639f26d66 in free () from /lib/libc.so.6
#18 0x00002ae63a67feeb in array_dealloc (self=0x9d9880) at
numpy/core/src/arrayobject.c:1954
#19 0x00002ae63a67a6d0 in PyArray_FromFile (fp=0x78d930,
dtype=0x2ae63a8ba020, num=4096,
    sep=<value optimized out>) at
numpy/core/src/multiarraymodule.c:6316
#20 0x00002ae63a67a804 in array_fromfile (ignored=<value optimized
out>, args=<value optimized out>,
    keywds=<value optimized out>) at
numpy/core/src/multiarraymodule.c:6361
#21 0x0000000000415520 in PyObject_Call ()
#22 0x0000000000473849 in PyEval_EvalFrame ()
#23 0x0000000000477905 in PyEval_EvalCodeEx ()
#24 0x0000000000477a32 in PyEval_EvalCode ()

Seems like the bad call is the Py_DECREF(ret); on line 6316 of
multiarraymodule.c, which occurs just after a PyDataMem_RENEW()
(i.e. realloc) call.

I tried to find recent changes in svn that might have caused this,
but couldn't see anything that seemed relevant.  One thing that
has changed recently on my system is that I'm now using the new
glibc (v2.7) on Debian unstable.

Let me know if you need more information.

Thanks,

Scott

-- 
Scott M. Ransom            Address:  NRAO
Phone:  (434) 296-0320               520 Edgemont Rd.
email:  sransom@nrao.edu             Charlottesville, VA 22903 USA
GPG Fingerprint: 06A9 9553 78BE 16DB 407B  FFCA 9BFA B6FF FFD3 2989


More information about the Numpy-discussion mailing list