[llvm] r317850 - [support] allocate exact size required for mapping in Support/Windws/Path.inc

Bob Haarman via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 16:17:31 PST 2017


Author: inglorion
Date: Thu Nov  9 16:17:31 2017
New Revision: 317850

URL: http://llvm.org/viewvc/llvm-project?rev=317850&view=rev
Log:
[support] allocate exact size required for mapping in Support/Windws/Path.inc

Summary:
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.

Reviewers: amccarth, zturner

Reviewed By: zturner

Subscribers: hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D39876

Modified:
    llvm/trunk/lib/Support/Windows/Path.inc

Modified: llvm/trunk/lib/Support/Windows/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?rev=317850&r1=317849&r2=317850&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Path.inc (original)
+++ llvm/trunk/lib/Support/Windows/Path.inc Thu Nov  9 16:17:31 2017
@@ -734,8 +734,8 @@ std::error_code mapped_file_region::init
 
   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());




More information about the llvm-commits mailing list