New submission from Hirokazu Yamamoto <ocean-c...@m2.ccsnet.ne.jp>:

I noticed following code crashes on windows. Attached patch will fix this.

/////////////////////////////////////
// Crash code

import mmap, tempfile
f = tempfile.TemporaryFile()
m1 = mmap.mmap(f.fileno(), 1000, tagname="foo")
m2 = mmap.mmap(f.fileno(), 5000, tagname="foo") # use same tagname, but
larger size
print len(m2[:]) # crash

/////////////////////////////////////
// After patch applied

Traceback (most recent call last):
  File "b.py", line 4, in <module>
    m2 = mmap.mmap(f.fileno(), 5000, tagname="foo")
WindowsError: [Error 5] アクセスが拒否されました。(Access Denied)
[15495 refs]

/////////////////////////////////////

Calling MapViewOfFile with size 0 means "map entire file", so
m2 = mmap.mmap(f.fileno(), 5000, tagname="foo")
maps existing memory region sized 1000. But mmap thinks its size is
5000, no IndexError raised, and accessed illegal memory area and crashes.

----------
components: Extension Modules, Windows
files: fix_tagname_crash.patch
keywords: patch
messages: 82561
nosy: ocean-city
severity: normal
status: open
title: mmap can crash with tagname (on windows)
type: crash
versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1
Added file: http://bugs.python.org/file13145/fix_tagname_crash.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5335>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to