[SciPy-dev] Memory error in interpolate.sproot
Pauli Virtanen
pav@iki...
Mon Nov 10 15:30:08 CST 2008
Mon, 10 Nov 2008 16:15:50 -0500, Nathan Bell wrote:
> On Mon, Nov 10, 2008 at 3:45 PM, Nils Wagner
> <nwagner@iam.uni-stuttgart.de> wrote:
>>
>> The same program works for me on my old 32bit laptop.
>>
>> Can somebody reproduce the problem on a 64-bit system ?
>>
>>
> Works for me. I get a plot and the following output:
>
> $ python -i test_iterpol.py
> Warning: the number of zeros exceeds mest
Valgrind spits out some warnings for me for the sproots line (Scipy r5054):
{{{
...
>>> y2 = splev(x2, tck)
>>> roots = sproot(tck, mest=2)
==4530==
==4530== Conditional jump or move depends on uninitialised value(s)
==4530== at 0x612DE8E: PyArray_NewFromDescr (arrayobject.c:5565)
==4530== by 0xADF5316: fitpack_sproot (__fitpack.h:518)
==4530== by 0x47F621: PyEval_EvalFrameEx (ceval.c:3566)
...
==4530== Conditional jump or move depends on uninitialised value(s)
==4530== at 0x612DE90: PyArray_NewFromDescr (arrayobject.c:5566)
==4530== by 0xADF5316: fitpack_sproot (__fitpack.h:518)
==4530== by 0x47F621: PyEval_EvalFrameEx (ceval.c:3566)
...
...
...
==4530== Conditional jump or move depends on uninitialised value(s)
==4530== at 0x4A1CFDA: memcpy (mc_replace_strmem.c:406)
==4530== by 0xADF5337: fitpack_sproot (__fitpack.h:520)
==4530== by 0x47F621: PyEval_EvalFrameEx (ceval.c:3566)
...
==4530== Conditional jump or move depends on uninitialised value(s)
==4530== at 0x4A1CFF9: memcpy (mc_replace_strmem.c:406)
==4530== by 0xADF5337: fitpack_sproot (__fitpack.h:520)
==4530== by 0x47F621: PyEval_EvalFrameEx (ceval.c:3566)
...
...
...
==4530== Use of uninitialised value of size 8
==4530== at 0x4A1D074: memcpy (mc_replace_strmem.c:406)
==4530== by 0xADF5337: fitpack_sproot (__fitpack.h:520)
==4530== by 0x47F621: PyEval_EvalFrameEx (ceval.c:3566)
...
...
Warning: the number of zeros exceeds mest
}}}
And... Bingo!
{{{
__fitpack.h:
512 if ((z = (double *)malloc(mest*sizeof(double)))==NULL) {
513 PyErr_NoMemory();
514 goto fail;
515 }
516 SPROOT(t,&n,c,z,&mest,&m,&ier);
517 if (ier==10) m=0;
518 ap_z = (PyArrayObject *)PyArray_SimpleNew(1,&m,PyArray_DOUBLE);
519 if (ap_z == NULL) goto fail;
520 memcpy(ap_z->data,z,m*sizeof(double));
}}}
Obviously, the last line should be mest*sizeof(double). I'll fix this.
--
Pauli Virtanen
More information about the Scipy-dev
mailing list