This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mmap can crash with tagname (on windows)
Type: crash Stage:
Components: Extension Modules, Windows Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: mmap.mmap can overrun buffer
View: 1733986
Assigned To: Nosy List: ocean-city
Priority: normal Keywords: patch

Created on 2009-02-21 06:24 by ocean-city, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_tagname_crash.patch ocean-city, 2009-02-21 06:24
Messages (2)
msg82561 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-02-21 06:24
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.
msg82667 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-02-24 16:51
This is duplicated issue of issue1733986. So I'll closing...
History
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49585
2009-02-24 16:51:20ocean-citysetstatus: open -> closed
resolution: duplicate
superseder: mmap.mmap can overrun buffer
messages: + msg82667
2009-02-21 06:24:56ocean-citycreate