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

Pearu Peterson pearu at scipy.org
Tue Oct 18 03:26:26 CDT 2005


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 */

gcc -I/home/pearu/svn/t/scipy/base/include -I/usr/include/python2.3 t.c 
-lpython2.3

./a.out
Hey
Segmentation fault

Pearu




More information about the Scipy-dev mailing list