# [SciPy-User] segfault using _sparse_ svd, eigen, eigen_symmetric with svn 0.9.0.dev6598

Wed Jul 21 10:59:45 CDT 2010

```Hi,

We are on a coding sprint trying to implement sparse matrix support in MDP (
http://sourceforge.net/apps/mediawiki/mdp-toolkit/index.php?title=MDP_Sprint_2010).
The new sparse.linalg is very useful here.

We are getting segfaults using _sparse_ svd, eigen, eigen_symmetric with svn
0.9.0.dev6598. I understand that (1) this is an unreleased version, and (2)
these methods may depend on external C and fortran code that could have not
being installed well on my machine, so this may be difficult to debug. I
anything else that could be needed and I'll try to provide it.

I installed the svn version on a virtualenv using pip:~/.virtualenvs/sprint\$
pip install svn+http://svn.scipy.org/svn/scipy/trunk/#egg=scipyc

This generates a long log that could contain the explanation, so I posted it
here (going as far back as my terminal's scrollback enabled:
http://pastebin.org/410867

Last, here's an example that reproduces the segfault:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

#--------------------------
# simply run an svd on a a sparse matrix, svn 0.9.0.dev6598
#--------------------------
import scipy
from scipy import sparse
from numpy.random import rand

# create random sparse matrix
x = scipy.sparse.lil_matrix((1000000, 1000000))
x[0, :100] = rand(100)
x[1, 100:200] = x[0, :100]
x.setdiag(rand(1000))
x = x.tocsr() # convert it to CSR
#v, u, w = scipy.sparse.linalg.eigen_symmetric(x) # segmentation fault

# try a simpler matrix
y = scipy.sparse.lil_matrix((10, 10))
y.setdiag(range(10))
y = y.tocsr() # convert it to CSR
#v, u, w = scipy.sparse.linalg.eigen_symmetric(y) #

#./sampleSegFault.py
#Traceback (most recent call last):
#File "./sampleSegFault.py", line 13, in <module>
#x[0, :100] = rand(100)
#File
line 319, in __setitem__
#x = lil_matrix(x, copy=False)
#File
line 98, in __init__
#A = csr_matrix(A, dtype=dtype).tolil()
#File
line 71, in __init__
#self._set_self( self.__class__(coo_matrix(arg1, dtype=dtype)) )
#File
line 171, in __init__
#self.data  = M[self.row,self.col]
#ValueError: shape mismatch: objects cannot be broadcast to a single
shape
#*** glibc detected *** python: double free or corruption (!prev):
0x0000000004075ec0 ***

# some other linalg methods
ly,v = scipy.sparse.linalg.eig(y) # segmentation fault

#====#

-Jose