[SciPy-dev] BUG: PyArray_FromDims|PyArray_SimpleNew causes segfault

Pearu Peterson pearu at scipy.org
Tue Oct 18 04:46:15 CDT 2005



On Tue, 18 Oct 2005, Pearu Peterson wrote:

>
> Hi Travis,
>
> I was investigating the reasons why newscipy extension modules crash with
> segfaults and found that this could be related to PyArray_FromDims (I got
> the same result with PyArray_SimpleNew) bug. Here's a simple test program
> demonstrating the bug:
>
> /* File t.c */
>
> #include <Python.h>
> #include <scipy/arrayobject.h>
>
> int main() {
>   PyArrayObject *arr = NULL;
>   int dims = {10};
>   printf("Hey\n");
>   //arr = (PyArrayObject *)PyArray_FromDims(1,dims,PyArray_DOUBLE);
>   arr = (PyArrayObject *)PyArray_SimpleNew(1,dims,PyArray_DOUBLE);
>   printf("Hi\n");
> }
> /* eof */

Actually, this is not a good example. Adding Py_Initialize(); fixes the 
segfault. However, f2py generated modules segfault in array_from_pyobj 
when calling PyArray_FromDims. Right now I'm not sure how to debug this 
further.

Pearu




More information about the Scipy-dev mailing list