[PATCH] D39876: [support] allocate exact size required for mapping in Support/Windws/Path.inc
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 14 10:29:28 PST 2017
On Thu, Nov 9, 2017 at 3:56 PM Bob Haarman via Phabricator <
reviews at reviews.llvm.org> wrote:
> 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,
Oops! Turns out this is undefined behavior when building x86 where size_t
is 32-bits, and you're shifting right by 32. I think we can replace this
with Hi_32 and Lo_32 instead. I'll fix it, just wanted to point it out.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171114/0df4123c/attachment.html>
More information about the llvm-commits
mailing list