[PATCH] D39876: [support] allocate exact size required for mapping in Support/Windws/Path.inc

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 15:56:12 PST 2017


inglorion created this revision.
Herald added a subscriber: hiraditya.

zturner suggested that mapped_file_region::init() on Windows seems to
create mappings that are larger than they need to be: Offset+Size
instead of Size. Indeed, that appears to be the case. I confirmed that
tests pass with mappings of just Size bytes, and fail with Size-1
bytes, suggesting that Size is indeed the correct value.


https://reviews.llvm.org/D39876

Files:
  llvm/lib/Support/Windows/Path.inc


Index: llvm/lib/Support/Windows/Path.inc
===================================================================
--- llvm/lib/Support/Windows/Path.inc
+++ llvm/lib/Support/Windows/Path.inc
@@ -734,8 +734,8 @@
 
   HANDLE FileMappingHandle =
       ::CreateFileMappingW(FileHandle, 0, flprotect,
-                           (Offset + Size) >> 32,
-                           (Offset + Size) & 0xffffffff,
+                           Size >> 32,
+                           Size & 0xffffffff,
                            0);
   if (FileMappingHandle == NULL) {
     std::error_code ec = mapWindowsError(GetLastError());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39876.122350.patch
Type: text/x-patch
Size: 614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171109/98dbfd80/attachment.bin>


More information about the llvm-commits mailing list