[PATCH] D52242: [sanitizer] Destroy and close a range's vmar if all its memory was unmapped
Kostya Kortchinsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 18 13:14:48 PDT 2018
cryptoad updated this revision to Diff 166023.
cryptoad marked an inline comment as done.
cryptoad added a comment.
Correct a comment to reflect that it is the destruction of the vmar that is
responsible for the unmapping.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D52242
Files:
lib/sanitizer_common/sanitizer_fuchsia.cc
Index: lib/sanitizer_common/sanitizer_fuchsia.cc
===================================================================
--- lib/sanitizer_common/sanitizer_fuchsia.cc
+++ lib/sanitizer_common/sanitizer_fuchsia.cc
@@ -277,14 +277,23 @@
void ReservedAddressRange::Unmap(uptr addr, uptr size) {
CHECK_LE(size, size_);
- if (addr == reinterpret_cast<uptr>(base_))
- // If we unmap the whole range, just null out the base.
- base_ = (size == size_) ? nullptr : reinterpret_cast<void*>(addr + size);
- else
+ const zx_handle_t vmar = static_cast<zx_handle_t>(os_handle_);
+ if (addr == reinterpret_cast<uptr>(base_)) {
+ if (size == size_) {
+ // Destroying the vmar effectively unmaps the whole mapping.
+ _zx_vmar_destroy(vmar);
+ _zx_handle_close(vmar);
+ os_handle_ = static_cast<uptr>(ZX_HANDLE_INVALID);
+ DecreaseTotalMmap(size);
+ return;
+ } else {
+ base_ = reinterpret_cast<void*>(addr + size);
+ }
+ } else {
CHECK_EQ(addr + size, reinterpret_cast<uptr>(base_) + size_);
+ }
size_ -= size;
- UnmapOrDieVmar(reinterpret_cast<void *>(addr), size,
- static_cast<zx_handle_t>(os_handle_));
+ UnmapOrDieVmar(reinterpret_cast<void *>(addr), size, vmar);
}
// This should never be called.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52242.166023.patch
Type: text/x-patch
Size: 1276 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180918/8e9d6141/attachment.bin>
More information about the llvm-commits
mailing list