[Scipy-tickets] [SciPy] #1210: crash during sparse matrix slicing with Python 2.7

SciPy Trac scipy-tickets@scipy....
Wed Jan 26 20:55:05 CST 2011


#1210: crash during sparse matrix slicing with Python 2.7
--------------------------+-------------------------------------------------
 Reporter:  cjgohlke      |       Owner:  wnbell      
     Type:  defect        |      Status:  needs_review
 Priority:  normal        |   Milestone:  0.9.0       
Component:  scipy.sparse  |     Version:  devel       
 Keywords:                |  
--------------------------+-------------------------------------------------

Comment(by cjgohlke):

 Using msvc9 builds of numpy 1.5.1 and scipy-0.9.0rc1, the scipy test suite
 crashes on win32-py2.7, win32-py3.1, win32-py3.2, win-amd64-py2.7, win-
 amd64-py3.1, and win-amd64-py3.2.

 When running the minimal example posted above, the crash occurs in the
 {{{_wrap_get_csr_submatrix__SWIG_5}}} function of csr_wrap.cxx, in the
 following line, when length == 0:

 {{{
 memcpy(PyArray_DATA(obj), &((*(arg11))[0]), sizeof(int)*length);
 }}}

 Using the following patch (requires "reswiging" the sources) seems to fix
 this issue and the complete scipy test suite finishes without crash or
 failures in sparse.tests:

 {{{
 Index: numpy.i
 ===================================================================
 --- numpy.i     (revision 7089)
 +++ numpy.i     (working copy)
 @@ -524,6 +524,7 @@
  %typemap( argout ) std::vector<ctype>* array_argout {
    npy_intp length = ($1)->size();
    PyObject *obj = PyArray_SimpleNew(1, &length, ##atype);
 +  if (length > 0)
    memcpy(PyArray_DATA(obj), &((*($1))[0]), sizeof(ctype)*length);
    delete $1;
    $result = helper_appendToTuple( $result, (PyObject *)obj );
 }}}

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


More information about the Scipy-tickets mailing list