Calling the close method of an mmap object more than
once would cause a segmentation fault for me (python
2.2.2, compiled with Sun's Forte compilers, though I
doubt that matters, Solaris 2.8 on an ultra-sparc).
The following code would do it reliably:
"""Demonstrate mmap bug?"""
import os
f=open('junk', 'w')
f.write(2**24 * 'a') # Arbitrary character
f.close()
s = os.stat('junk')
s.st_size
from mmap import *
f = open('junk')
mf = mmap(f.fileno(), 2**24, access=ACCESS_READ)
print mf[0], mf[2**23]
mf.close()
mf.close()
The problem seems to be that mmap_close_method does an
munmap of the data and then sets it to NULL without
checking first whether the data pointer is already
NULL. The windows part already checks this. (Please
excuse me if I mess up the protocol for suggesting
patches.)
|