[Patches] [ python-Patches-665913 ] Fix mmap module core dump with unix

SourceForge.net noreply@sourceforge.net
Fri, 10 Jan 2003 11:03:55 -0800


Patches item #665913, was opened at 2003-01-10 14:03
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=665913&group_id=5470

Category: Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Clay Spence (cspence)
Assigned to: Nobody/Anonymous (nobody)
Summary: Fix mmap module core dump with unix

Initial Comment:
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.)


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=665913&group_id=5470