[Scipy-tickets] [SciPy] #1141: orthogonal_eval crashes

SciPy Trac scipy-tickets@scipy....
Fri May 28 14:58:48 CDT 2010

#1141: orthogonal_eval crashes
 Reporter:  cjgohlke       |       Owner:  pv   
     Type:  defect         |      Status:  new  
 Priority:  normal         |   Milestone:  0.8.0
Component:  scipy.special  |     Version:  devel
 Keywords:                 |  

Comment(by cjgohlke):

 This is the minimal Cython code that I can come up with, which reproduces
 the issue when built with Cython 0.12.1 and msvc9. It crashes in the
 eval_poly_chebyt function when using the numpy ufunc machinery, but not
 when called directly. Note that this example can be built and executed
 independent of scipy and does not perform any numeric calculations.
 Clearly, this is not a scipy issue and should probably be discussed


 cdef eval_poly_chebyt():
     cdef long m
     for m in range(0, 0, -1):  # <-- crash when used in _eval_chebyt()
     #for m in range(0):  # <-- works

 cdef extern from "numpy/arrayobject.h":
     void import_array()
     ctypedef int npy_intp
     cdef enum NPY_TYPES:

 cdef extern from "numpy/ufuncobject.h":
     void import_ufunc()
     ctypedef void (*PyUFuncGenericFunction)(char**, npy_intp*, npy_intp*,
     object PyUFunc_FromFuncAndData(PyUFuncGenericFunction* func, void**
                                    char* types, int ntypes, int nin, int
                                    int identity, char* name, char* doc,
 int c)

 cdef void _loop_id_d(char **args, npy_intp *dimensions, npy_intp *steps,
 void *func):
     cdef npy_intp i
     for i in range(0, dimensions[0]):

 cdef char _id_d_types[1]
 cdef PyUFuncGenericFunction _id_d_funcs[1]

 _id_d_types[0] = NPY_DOUBLE
 _id_d_funcs[0] = _loop_id_d


 cdef void *chebyt_data[1]
 chebyt_data[0] = <void*>eval_poly_chebyt
 _eval_chebyt = PyUFunc_FromFuncAndData(_id_d_funcs, chebyt_data,
                                        _id_d_types, 1, 0, 0, 0, "", "", 0)

 def eval_chebyt():
     #return eval_poly_chebyt()  # <-- works
     return _eval_chebyt()  # <-- crash


 # run 'python test_orthogonal_eval.py build_ext --inplace'

 from distutils.core import setup
 from distutils.extension import Extension
 from Cython.Distutils import build_ext
 ext_modules = [Extension("_orthogonal_eval", ["orthogonal_eval.pyx"])]
     name = "Crash in range function",
     cmdclass = {"build_ext": build_ext},
     ext_modules = ext_modules

 print "testing eval_chebyt...",
 from _orthogonal_eval import eval_chebyt
 eval_chebyt()  # <-- crash
 print "ok"

Ticket URL: <http://projects.scipy.org/scipy/ticket/1141#comment:11>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.

More information about the Scipy-tickets mailing list