thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

functions returned by frompyfunc() cause segmentation faults (Trac #1416) #5219

Open numpy-gitbot opened 12 years ago

numpy-gitbot commented 12 years ago

_Original ticket http://projects.scipy.org/numpy/ticket/1416 on 2010-02-28 by trac user ernestac, assigned to unknown.

When called with a last argument equal to zero, frompyfunc produces a function that segfaults on execution. Example:

In [3]: f = np.frompyfunc(lambda x: x, 1, 0)
In [4]: f([1,2,3])
<segmentation fault>

Observed in Numpy 1.3.0 and in more recent versions.

numpy-gitbot commented 12 years ago

atmention:nilswagner01 wrote on 2010-02-28

Confirmed.

{{{>>> numpy.version '2.0.0.dev8269' }}}

Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21)                                     
[GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2                               
Type "help", "copyright", "credits" or "license" for more information.               
>>> import numpy as np                                                          
>>> f = np.frompyfunc(lambda x: x, 1, 0)                                        
>>> f([1,2,3])                                                                  

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff60cc15e in PyUFunc_On_Om (args=<value optimized out>, dimensions=<value optimized out>, 
    steps=0xae99f0, func=<value optimized out>) at numpy/core/src/umath/loops.c.src:434            
434                 Py_XDECREF(*op);
(gdb) bt
#0  0x00007ffff60cc15e in PyUFunc_On_Om (args=<value optimized out>, dimensions=<value optimized out>,
    steps=0xae99f0, func=<value optimized out>) at numpy/core/src/umath/loops.c.src:434
#1  0x00007ffff60ce819 in PyUFunc_GenericFunction (self=<value optimized out>,
    args=<value optimized out>, kwds=0x0, mps=<value optimized out>)
    at numpy/core/src/umath/ufunc_object.c:2070
#2  0x00007ffff60cf3c3 in ufunc_generic_call (self=0x8a9000, args=<value optimized out>, kwds=0x60b5f8)
    at numpy/core/src/umath/ufunc_object.c:3533
#3  0x00007ffff7a9de32 in PyObject_Call (func=0x8a9000, arg=0x7ffff7ed5950, kw=0x60b5f8)
    at Objects/abstract.c:2492
#4  0x00007ffff7b1aab4 in do_call (nk=<value optimized out>, na=1, pp_stack=<value optimized out>,
    func=<value optimized out>) at Python/ceval.c:3917
#5  call_function (nk=<value optimized out>, na=1, pp_stack=<value optimized out>,
    func=<value optimized out>) at Python/ceval.c:3729
#6  PyEval_EvalFrameEx (nk=<value optimized out>, na=1, pp_stack=<value optimized out>,
    func=<value optimized out>) at Python/ceval.c:2389
#7  0x00007ffff7b1f735 in PyEval_EvalCodeEx (co=0x7ffff7ed3990, globals=<value optimized out>,
    locals=<value optimized out>, args=0x0, argcount=-134504368, kws=<value optimized out>, kwcount=0,
    defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:2968
#8  0x00007ffff7b18642 in PyEval_EvalCode (co=0x7ffff7ed5910, globals=0x7ffff7ed5950, locals=0x60b5f8)
    at Python/ceval.c:522
#9  0x00007ffff7b37971 in run_mod (mod=<value optimized out>, filename=<value optimized out>,
    globals=0x62d750, locals=0x62d750, flags=<value optimized out>, arena=<value optimized out>)
    at Python/pythonrun.c:1335
#10 0x00007ffff7b39e2c in PyRun_InteractiveOneFlags (fp=<value optimized out>,
    filename=0x7ffff7b6fe1f "<stdin>", flags=0x7fffffffd8b0) at Python/pythonrun.c:840
#11 0x00007ffff7b39f60 in PyRun_InteractiveLoopFlags (fp=0x7ffff71d86a0,
    filename=0x7ffff7b6fe1f "<stdin>", flags=0x7fffffffd8b0) at Python/pythonrun.c:760
#12 0x00007ffff7b38604 in PyRun_AnyFileExFlags (fp=0x7ffff71d86a0, filename=0x7ffff7b6fe1f "<stdin>",
    closeit=0, flags=0x7fffffffd8b0) at Python/pythonrun.c:729
#13 0x00007ffff7b42e6e in Py_Main (argc=<value optimized out>, argv=<value optimized out>)
    at Modules/main.c:599
#14 0x00007ffff6ea1a7d in __libc_start_main () from /lib64/libc.so.6
#15 0x00000000004006e9 in _start () at ../sysdeps/x86_64/elf/start.S:113
numpy-gitbot commented 12 years ago

atmention:rgommers wrote on 2010-06-02

Confirmed.

numpy-gitbot commented 12 years ago

atmention:pv wrote on 2010-09-05

Doesn't crash with

>>> f = np.frompyfunc(lambda x: x, 1, 1)
>>> f([1,2,3])
array([1, 2, 3], dtype=object)

Seems like it doesn't like invalid values for the nin or nout parameters.