delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/08/13/17:58:36

From: Fuehrer AT seabase DOT com (Gary Fuehrer)
Subject: mmap(,,,MAP_PRIVATE,,) bug and fix
13 Aug 1997 17:58:36 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <6CC63E2E4FC1D011A2A700609716117A266F05.cygnus.gnu-win32@seawolf>
Mime-Version: 1.0
Original-To: "'gnu-win32 AT cygnus DOT com'" <gnu-win32 AT cygnus DOT com>
X-Priority: 3
X-Mailer: Internet Mail Service (5.0.1458.49)
Original-Sender: owner-gnu-win32 AT cygnus DOT com

The B18 implementation of mmap() fails when MAP_PRIVATE is used.

The problem is caused because of this pair of lines in mmap.cc:
  DWORD access = (prot & PROT_WRITE) ? FILE_MAP_WRITE : FILE_MAP_READ;


access |= (flags & MAP_PRIVATE) ? FILE_MAP_COPY : 0;


When MAP_PRIVATE is set, then "access" = "FILE_MAP_READ/WRITE |
MAP_PRIVATE".  When "access" is subsequently passed to MapViewOfFile(),
it fails.  The Microsoft documentation for MapViewOfFile() states the
following concerning the access parameter:
"This parameter can be one of the following values:...".  So, the
failure is because of trying to use more than one of the access types at
the same time.

Fix:  Change the above lines of code to the following (only the second
line is different):
  DWORD access = (prot & PROT_WRITE) ? FILE_MAP_WRITE : FILE_MAP_READ;


if (flags & MAP_PRIVATE) access = FILE_MAP_COPY;


I've tested this change and it seems to work correctly.  Will this fix
make it in for B19?

Gary

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019