[NumPy-Tickets] [NumPy] #2148: Bus error/seg fault when using flat on sliced, memmap'd array
NumPy Trac
numpy-tickets@scipy....
Thu May 31 07:50:12 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: |
----------------------+-----------------------------------------------------
The following code crashes on numpy 1.6.1, on OSX 10.6.
{{{
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]
np.sum(arr.flat)
}}}
Here's what I've discovered so far about this:
- the bus error only occurs with mode 'r'
- the dimensionality of the array appears to be irrelevant
- if the array slice does not change the strides, the bus error does not
occur
- no 'arr.flat', no bus error
- Other aggregating functions (e.g. fmin.reduce) will induce the error
- Iterating over arr.flat will *not* cause a bus error
Based on this, I suspect the issue is with the C-facing side of the flat
iterator.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/2148>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list