[Numpy-tickets] [NumPy] #548: fromfile crashes due to failed allocation
NumPy
numpy-tickets@scipy....
Tue Jul 10 03:41:14 CDT 2007
#548: fromfile crashes due to failed allocation
-----------------------------+----------------------------------------------
Reporter: albertstrasheim | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.0.4 Release
Component: numpy.core | Version: none
Severity: major | Keywords:
-----------------------------+----------------------------------------------
I'm seeing a crash that appears to be due to fromfile or something it
calls ignoring a failed allocation.
Code to reproduce:
{{{
import numpy as N
def main():
dtype = N.dtype('f4')
iocount = 6
x = N.zeros((33554432,), dtype=dtype)
assert x.nbytes == 128 * 1024 * 1024
count = len(x)
print 'writing'
fp = open('matrix.out', 'wb')
for i in xrange(iocount):
x.tofile(fp)
fp.close()
del x
fp = open('matrix.out', 'rb')
toomuch = []
for i in xrange(100):
print i
fp.seek(0)
y = N.fromfile(fp, dtype=dtype, count=5*count)
print len(y)
toomuch.append(y)
fp.close()
if __name__ == '__main__':
main()
}}}
Output on my Windows machine, which can't handle more than one 640 MB
allocation even though it has 2 GB RAM (heap fragmentation rocks):
{{{
writing
0
167772160
1
167772160 items requested but only 0 read
}}}
Crash dialog:
{{{
---------------------------
python.exe - Application Error
---------------------------
The instruction at "0x10022439" referenced memory at "0x0000001c". The
memory could not be "read".
Click on OK to terminate the program
Click on CANCEL to debug the program
---------------------------
OK Cancel
---------------------------
}}}
--
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/548>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list