Title: mmap crash on Windows with out of range file descriptor
Type: crash Stage: resolved
Components: Extension Modules, Windows Versions: Python 3.1, Python 3.2, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brian.curtin Nosy List: brian.curtin, georg.brandl
Priority: normal Keywords: patch

Created on 2010-03-10 00:42 by brian.curtin, last changed 2010-08-01 15:50 by brian.curtin. This issue is now closed.

File name Uploaded Description Edit
mmap_crash.diff brian.curtin, 2010-03-10 00:43
Messages (4)
msg100774 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-03-10 00:42
Creating an mmap object can crash the interpreter on Windows if a file descriptor is passed in which is outside of the range for _get_osfhandle. I noticed the crash possibility while reviewing the Modules/mmapmodule.c code for work on another issue related to the consistency of the exceptions which mmap raises.

This can be tested by creating a mmap object with the file descriptor for a socket. This is not a valid way to create an mmap, but it represents a valid file descriptor which is out of range. For example, I created a socket with a file descriptor of 124, and _get_osfhandle expects the descriptor to be between 0 and 23.

Patch against trunk, with a test.

Note that this does not seem to affect 2.6 (not sure why, yet).
msg100775 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-03-10 00:52
I should add that I tried the same thing on linux and no crash occured, it properly raised an exception.
msg112278 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-08-01 07:59
What's the status here?  Can it be committed?
msg112347 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-08-01 15:50
Fixed in r83407 (py3k), r83409 (release31-maint), and r83410 (release27-maint).
Date User Action Args
2010-08-01 15:50:08brian.curtinsetstatus: open -> closed
messages: + msg112347

assignee: brian.curtin
components: + Extension Modules, - Library (Lib)
resolution: fixed
stage: patch review -> resolved
2010-08-01 07:59:08georg.brandlsetnosy: + georg.brandl
messages: + msg112278
2010-03-10 00:52:28brian.curtinsetmessages: + msg100775
2010-03-10 00:43:48brian.curtinsetfiles: + mmap_crash.diff
2010-03-10 00:43:38brian.curtinsetfiles: - mmap_crash.diff
2010-03-10 00:42:24brian.curtincreate