[NumPy-Tickets] [NumPy] #2148: Bus error/seg fault when using flat on sliced, memmap'd array

NumPy Trac numpy-tickets@scipy....
Thu May 31 10:55:06 CDT 2012


#2148: Bus error/seg fault when using flat on sliced, memmap'd array
----------------------+-----------------------------------------------------
 Reporter:  farrowch  |       Owner:  somebody   
     Type:  defect    |      Status:  new        
 Priority:  normal    |   Milestone:  Unscheduled
Component:  Other     |     Version:  1.6.1      
 Keywords:            |  
----------------------+-----------------------------------------------------

Comment(by mwiebe):

 It looks like the problem is that the flat iterator generates an
 UPDATEIFCOPY array whenever an array version of it is requested, and that
 leads to the following sequence of events:

  - Operation requests array from flatiter
  - Flatiter gives back UPDATEIFCOPY array
  - Operation completes, triggers UPDATEIFCOPY
  - Segfault because memmap marked the memory as read only at the OS level

 This simpler version also triggers it for me:

 {{{
 import numpy as np
 shape = (8, 8)
 dtype = np.dtype(np.uint8)
 image = np.random.randint(0, 256, shape).astype(dtype)
 image.tofile("test_image.bin")
 image = np.memmap("test_image.bin", dtype=dtype, shape=shape, mode='r')
 arr = image[::2,::2]
 temp = np.asarray(arr)
 del(temp) # triggers UPDATEIFCOPY, crash
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/2148#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list