[NumPy-Tickets] [NumPy] #2250: array "reshape" crashes when size in one dimension is greater than 2^31

NumPy Trac numpy-tickets@scipy....
Wed Nov 21 07:09:27 CST 2012

#2250: array "reshape" crashes when size in one dimension is greater than 2^31
 Reporter:  tjligocki   |       Owner:  somebody   
     Type:  defect      |      Status:  new        
 Priority:  normal      |   Milestone:  Unscheduled
Component:  numpy.core  |     Version:  1.6.2      
 Keywords:              |  
 I am having a problem with "reshape" crashing:

  > python[[BR]]
  Python 2.6.4 (r264:75706, Jan 16 2010, 21:11:47)[[BR]]
  [GCC 4.3.2] on linux2[[BR]]
  Type "help", "copyright", "credits" or "license" for more
  >>> import numpy[[BR]]
  >>> numpy.version.version[[BR]]
  >>> npData = numpy.ones([701,701,7899],dtype=numpy.dtype('b'))[[BR]]
  >>> npDataSubset = npData[ [slice(0,700),slice(0,700),slice(0,5000)]
  >>> npDataOutput = npDataSubset.reshape([700*700*5000],order='F')[[BR]]
  Segmentation fault[[BR]]

 If I change the "5000" to a "4000", everything is fine.  I'm not running
 out of memory - my system had 48 GB of memory and nothing else is using a
 significant portion of this memory.

 Note:  700x700x4000 = 1,960,000,000 < 2**31 and 700x700x5000 = 2450000000
 > 2**31.  I suspect somewhere in the underlying code there is a signed
 32-bit integer being used for an index/pointer offset (this is running on
 a 64-bit machine).

 I did some searching of the archives and didn't find a match for this
 problem and posted to the numpy-discussion group.  Francesc Alted
 suggested I submit a ticket.

 Thank you for any and all help!

Ticket URL: <http://projects.scipy.org/numpy/ticket/2250>
NumPy <http://projects.scipy.org/numpy>
My example project

More information about the NumPy-Tickets mailing list