This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

mmap(,,,MAP_PRIVATE,,) bug and fix


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@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]