[Scipy-tickets] [SciPy] #794: linalg.eig segmentation fault on unpickled arrays

SciPy scipy-tickets@scipy....
Thu Nov 20 03:16:49 CST 2008


#794: linalg.eig segmentation fault on unpickled arrays
--------------------------+-------------------------------------------------
 Reporter:  tzito         |        Owner:  somebody
     Type:  defect        |       Status:  new     
 Priority:  high          |    Milestone:  0.7.0   
Component:  scipy.linalg  |      Version:          
 Severity:  critical      |   Resolution:          
 Keywords:                |  
--------------------------+-------------------------------------------------
Comment (by tzito):

 Some more information:

 The transpose is needed to generate the segfault because the non-
 transposed array is C-contiguous and the underlying LAPACK wrapper will
 perform a copy, in order to feed the fortran routine with a F-contiguous
 array.

 The transposed array is F-contiguous, so the wrapper does not perform the
 copy and, because overwrite_a=True, it tries to write on top of that.

 It then fails probably because the array is neither C- nor F- contiguous,
 but it's somehow messed up after unpickling. As a summary, try the
 following code:

 {{{
 import scipy
 import scipy.linalg
 import pickle

 N = 100
 x = scipy.random.random((N, N))
 y = x.copy()
 print y.flags.c_contiguous, y.flags.f_contiguous
 print y.T.flags.c_contiguous, y.T.flags.f_contiguous
 out = scipy.linalg.eig(y.T, overwrite_a=True)
 print "OK"
 s = pickle.dumps(x)
 yp = pickle.loads(s)
 print yp.flags.c_contiguous, yp.flags.f_contiguous
 print yp.T.flags.c_contiguous, y.T.flags.f_contiguous
 out = scipy.linalg.eig(yp.T, overwrite_a=True)
 print "OK"
 }}}

 It gives (when ATLAS SSE2 in installed):

 {{{
 True False
 False True
 OK
 True False
 False True
 Segmentation fault
 }}}

 To show that a copy it's indeed enough to avoid the segfault try:

 {{{
 import scipy
 import scipy.linalg
 import pickle

 N = 100
 x = scipy.random.random((N, N))
 y = x.copy()
 out = scipy.linalg.eig(y.T, overwrite_a=True)
 print "OK"
 s = pickle.dumps(x)
 yp = pickle.loads(s)
 yp_c = yp.copy()
 out = scipy.linalg.eig(yp_c.T, overwrite_a=True)
 print "OK"
 }}}

 It shows:

 {{{
 OK
 OK
 }}}

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


More information about the Scipy-tickets mailing list