mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #5385: Fixed mmap crash after resize failure on windows.
Now uses NULL instead of INVALID_HANDLE_VALUE as invalid map handle because CreateFileMapping returns NULL when error occurs.
This commit is contained in:
parent
a3e6c9763c
commit
264fc12fbf
3 changed files with 48 additions and 7 deletions
|
@ -504,6 +504,7 @@ class MmapTests(unittest.TestCase):
|
|||
data1 = "0123456789"
|
||||
data2 = "abcdefghij"
|
||||
assert len(data1) == len(data2)
|
||||
|
||||
# Test same tag
|
||||
m1 = mmap.mmap(-1, len(data1), tagname="foo")
|
||||
m1[:] = data1
|
||||
|
@ -511,6 +512,9 @@ class MmapTests(unittest.TestCase):
|
|||
m2[:] = data2
|
||||
self.assertEquals(m1[:], data2)
|
||||
self.assertEquals(m2[:], data2)
|
||||
m2.close()
|
||||
m1.close()
|
||||
|
||||
# Test differnt tag
|
||||
m1 = mmap.mmap(-1, len(data1), tagname="foo")
|
||||
m1[:] = data1
|
||||
|
@ -518,14 +522,42 @@ class MmapTests(unittest.TestCase):
|
|||
m2[:] = data2
|
||||
self.assertEquals(m1[:], data1)
|
||||
self.assertEquals(m2[:], data2)
|
||||
m2.close()
|
||||
m1.close()
|
||||
|
||||
def test_tagname_crash(self):
|
||||
def test_crasher_on_windows(self):
|
||||
# Should not crash (Issue 1733986)
|
||||
m = mmap.mmap(-1, 1000, tagname="foo")
|
||||
try:
|
||||
mmap.mmap(-1, 5000, tagname="foo")[:] # same tagname, but larger size
|
||||
except:
|
||||
pass
|
||||
m.close()
|
||||
|
||||
# Should not crash (Issue 5385)
|
||||
m = mmap.mmap(-1, 1000)
|
||||
try:
|
||||
m.resize(0)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
m[:]
|
||||
except:
|
||||
pass
|
||||
m.close()
|
||||
|
||||
m1 = mmap.mmap(-1, 1000)
|
||||
m2 = mmap.mmap(-1, 1000)
|
||||
try:
|
||||
m2.resize(5000)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
m2[:]
|
||||
except:
|
||||
pass
|
||||
m2.close()
|
||||
m1.close()
|
||||
|
||||
|
||||
def test_main():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue