[Numpy-tickets] [NumPy] #466: Segmentation fault when reversing an array enough times

NumPy numpy-tickets@scipy....
Sun Apr 1 12:24:26 CDT 2007


#466: Segmentation fault when reversing an array enough times
------------------------+---------------------------------------------------
 Reporter:  faltet      |        Owner:  somebody
     Type:  defect      |       Status:  new     
 Priority:  normal      |    Milestone:          
Component:  numpy.core  |      Version:  devel   
 Severity:  normal      |   Resolution:          
 Keywords:              |  
------------------------+---------------------------------------------------
Comment (by pv):

 Not only does [::-1] crash, but also the following loops cause a crash:
 {{{
 for i in xrange(N):
     a = a.T
 }}}
 {{{
 for i in xrange(N):
     a = a[:]
 }}}
 I notice that on each iteration, some memory is reserved, and the size of
 the python process grows continuously while the loop is running.

 The following does not exhibit this behavior:
 {{{
 for i in xrange(N):
     a = numpy.array(a[::-1], copy=True)
 }}}

 I think that the code makes numpy to generate a chain of views, unlimited
 in length, each referring to its parent. The bottom views are never freed
 before the topmost one, which causes memory hogging and everything to be
 freed only when the program ends. When freeing, DECREFing self->base calls
 array_dealloc recursively until stack overflows.

 If this hypothesis is correct, could the problem be fixed by walking
 self->base pointers upwards always when creating new views?

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/466#comment:2>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list