[SciPy-Dev] Weird segfault in call to PyArray_SIZE

Jaime Fernández del Río jaime.frio at gmail.com
Mon Jun 26 09:34:23 EDT 2017


On Mon, Jun 26, 2017 at 2:51 PM, Ralf Gommers <ralf.gommers at gmail.com>
wrote:

>
>
> On Mon, Jun 26, 2017 at 9:08 AM, Jaime Fernández del Río <
> jaime.frio at gmail.com> wrote:
>
>> While working in scipy.ndimage I tried to replace the following code, see
>> here
>> <https://github.com/scipy/scipy/blob/master/scipy/ndimage/src/ni_support.c#L95> for
>> the source:
>>
>> npy_intp max_lines;
>> int ii;
>>
>> for (ii = 0; ii < array->nd; ii++)
>>     max_lines *= array->dimensions[ii];
>>
>> with the in theory equivalent:
>>
>> max_lines = PyArray_SIZE(array);
>>
>> Oddly enough, the result is a segfault as soon as PyArray_SIZE is
>> called, e.g. by running the ndimage tests.
>>
>> Both numpy and scipy are the latest development versions, built by myself
>> on OSX. Unfortunately I don't have Python and friends built with debug
>> symbols, so the best I have been able to figure out, through printf
>> debugging, is that the segfault happens before PyArray_MultiplyList is
>> entered, which made me suspicious of it being related to import_array()
>> not being called, but that doesn't seem to be the case.
>>
>
> Even if it's not the cause here, that ``#undef NO_IMPORT_ARRAY`` looks
> quite odd, it's the only place in scipy or numpy where that is done. May be
> good to get rid of it.
>

I played a little bit with it yesterday and it did not seem to be the cause.

We should actually move to using the usual numpy types and get rid of the
#include <numpy/noprefix.h> and the surrounding #define/#undef dance
altogether, yes.

Jaime

-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes
de dominación mundial.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20170626/589189df/attachment.html>


More information about the SciPy-Dev mailing list