[PATCH] D17431: [Windows] Fix UnmapOrDie and MmapAlignedOrDie

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 18 17:53:27 PST 2016


rnk created this revision.
rnk added reviewers: kcc, samsonov.
rnk added a subscriber: llvm-commits.

Now ASan can return virtual memory to the underlying OS. Portable
sanitizer runtime code needs to be aware that UnmapOrDie cannot unmap
part of previous mapping.

In particular, this required changing how we implement MmapAlignedOrDie
on Windows, which is what Allocator32 uses.

The new code first attempts to allocate memory of the given size, and if
it is appropriately aligned, returns early. If not, it frees the memory
and attempts to reserve size + alignment bytes. In this region there
must be an aligned address. We then free the oversized mapping and
request a new mapping at the aligned address immediately after. However,
a thread could allocate that virtual address in between our free and
allocation, so we have to retry if that allocation fails. The existing
thread creation stress test managed to trigger this condition, so the
code isn't totally untested.

http://reviews.llvm.org/D17431

Files:
  lib/sanitizer_common/sanitizer_common.cc
  lib/sanitizer_common/sanitizer_posix.cc
  lib/sanitizer_common/sanitizer_win.cc
  test/asan/TestCases/Windows/oom.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17431.48442.patch
Type: text/x-patch
Size: 6771 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160219/0a86ba39/attachment.bin>


More information about the llvm-commits mailing list