# [SciPy-user] scipy general_function segfault

Arnd Baecker scipy-user@scipy.net
Thu, 18 Sep 2003 18:34:59 +0200 (CEST)

```Hi,

a few more pieces for the puzzle:

a) I also tried the following variants, all leading to a segfault:

from scipy import *

if a > b:
return a - b
else:
return a + b

gfunc([0,3,6,9],[1,3,5,7])

""" This is different"""
return a+b

gfunc2([0,3,6,9],[1,3,5,7])

gfunc2(1,2)

def justreturna(a,b):
return a

gfunc2([0,3,6,9],[1,3,5,7])

gfunc3(1,2)

# this gives the right error message:
nofct=10
gfunc=special.general_function(nofct)

b) Instead of libwadpy I used a set of print /printfs to isolate
the problem a little bit.
The segfault occurs in the arraymap call of the __call__ method
of general_function in scipy/special/basic.py.

Then a few printf's in  special/cephesmodule.c
in the routine after

/* ************************ */
static char arraymap_doc[] = "c1,..,cn =
arraymap(pyfunc,inputs{,outputtypes})\n\n  Loop over the elements of the
inputs tuple, applying pyfunc to the set\n  formed from each element of
inputs.  Place the output in arrays c1,...,cn.\n  This function can make
any pyfunc with scalar inputs and scalar outputs\n  emulate a ufunc.\n";

static PyObject *map_PyFunc(PyObject *self, PyObject *args)
{

[...]
printf("Alive0c\n");  fflush(stdout);
if (setup_input_arrays(inputs,inputarrays,nin) == -1) {
printf("try to free ....");  fflush(stdout);
free(inputarrays);
return NULL;
}

printf("Alive1\n");  fflush(stdout);
[...]
/* ************************ */

show that
Alive0c shows up and next the segfault happens.

Hmm, does this help in any way ?

Pearu wrote:

> I'll later try if I can figure out something from my case where
> general_function segfaulted.
It would be interesting, if this is the same place as above ...

(still I somehow feal/fear that the segfault is due
to some installation error on my side ...)

Arnd

```