[SciPy-dev] Core dump in PyArray_Return
Travis Oliphant
oliphant.travis at ieee.org
Sun Jan 8 21:03:53 CST 2006
Sasha wrote:
>I cannot reproduce the problem with a small example, but the following
>change fixes it:
>
>Index: numpy/core/src/arrayobject.c
>===================================================================
>--- numpy/core/src/arrayobject.c (revision 1855)
>+++ numpy/core/src/arrayobject.c (working copy)
>@@ -915,8 +915,7 @@
> Py_XDECREF(mp);
> return NULL;
> }
>-
>- if (mp->nd == 0) {
>+ if (mp->nd == 0 && !PyArray_IsScalar(mp, Generic)) {
> PyObject *ret;
> ret = PyArray_ToScalar(mp->data, mp);
> Py_DECREF(mp);
>
>Apparently in my program PyArray_Return somehow gets an object that is
>already a scalar and calls PyArray_ToScalar on it.
>
I've seen this before during development. It typically is due to a
PyArray_Return on something that already returns a scalar. It would be
nice to know where the core dump occurred. I think a check like this is
probably in order though... just added it.
I also undid the size-0 check. It was added to fix the "problem" that
several places in the code where an array can be copied into another
array many times. That is a size-10 array can be used to fill a
size-100 array by repeating over it 10 times. The code uses iterators
to do it, and there are a few places where you can even put a size-20
array into a size-13 array and a fraction of it will be iterated over.
I guess the universal check is to stringent and the size-0 check should
be placed in those places where copying data from a size-0 array makes
no sense...
-Travis
More information about the Scipy-dev
mailing list