[Numpy-discussion] PyArray_SimpleNewFromData segfaults
Mon Oct 5 22:38:18 CDT 2009
On Mon, Oct 5, 2009 at 7:34 PM, Charles R Harris
> On Mon, Oct 5, 2009 at 7:40 PM, Ondrej Certik <firstname.lastname@example.org> wrote:
>> still alive
>> Segmentation fault
>> What puzzles me is that there is no debugging print statement just
>> before the segfault.
> Maybe you need to flush the buffer. That is a good thing to do when
> segfaults are about.
I tried to put "fflush(NULL);" after it, but it didn't help. I have
created a super simple demo for anyone to play:
$ git clone git://github.com/certik/segfault.git
$ cd segfault/
$ vim Makefile # <-- edit the python and numpy include paths
$ python test.py
I am still alive
where test.py is:
$ cat test.py
v = _hermes1d.test()
and _hermes1d.pyx is:
$ cat _hermes1d.pyx
cdef npy_intp size
cdef ndarray newarr
cdef double *arrsource
size = 10
arrsource = <double *>malloc(sizeof(double) * size)
print "I am still alive"
newarr = PyArray_SimpleNewFromData(1, &size, NPY_DOUBLE, <void *>arrsource)
print "I am dead."
So I bet there is something very stupid that I am missing. Still
More information about the NumPy-Discussion