summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2017-10-30 19:06:59 +0000
committerKostya Kortchinsky <kostyak@google.com>2017-10-30 19:06:59 +0000
commit7ff86c1f9a06dad5f5590544e7667666dbd162ba (patch)
treefe4bb9f7dd6994e299aa620c2f2e50c96e40fcc7 /lib
parent97cfd35230e2c94336af31395f2d86b978d3486c (diff)
Fix warning + death test + failing test on Windows (D39072).
Summary: Fixes https://reviews.llvm.org/D39072 Reviewers: cryptoad Reviewed By: cryptoad Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D39427 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316943 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/sanitizer_common/sanitizer_win.cc4
-rw-r--r--lib/sanitizer_common/tests/sanitizer_common_test.cc12
2 files changed, 7 insertions, 9 deletions
diff --git a/lib/sanitizer_common/sanitizer_win.cc b/lib/sanitizer_common/sanitizer_win.cc
index b490601a0..b2fd8baca 100644
--- a/lib/sanitizer_common/sanitizer_win.cc
+++ b/lib/sanitizer_common/sanitizer_win.cc
@@ -249,8 +249,8 @@ void ReservedAddressRange::Unmap(uptr addr, uptr size) {
void* addr_as_void = reinterpret_cast<void*>(addr);
uptr base_as_uptr = reinterpret_cast<uptr>(base_);
// Only unmap if it covers the entire range.
- CHECK((addr_as_void == base_) && (size == size_));
- UnmapOrDie(reinterpret_cast<void*>(addr), size);
+ CHECK((addr == base_as_uptr) && (size == size_));
+ UnmapOrDie(addr_as_void, size);
}
void *MmapFixedOrDieOnFatalError(uptr fixed_addr, uptr size) {
diff --git a/lib/sanitizer_common/tests/sanitizer_common_test.cc b/lib/sanitizer_common/tests/sanitizer_common_test.cc
index 38170ea6d..576649cea 100644
--- a/lib/sanitizer_common/tests/sanitizer_common_test.cc
+++ b/lib/sanitizer_common/tests/sanitizer_common_test.cc
@@ -349,25 +349,23 @@ TEST(SanitizerCommon, ReservedAddressRangeMap) {
unsigned char buffer[init_size];
memcpy(buffer, reinterpret_cast<void *>(res), init_size);
- // Invalid mappings should fail.
- EXPECT_DEATH(address_range.Map(res, 0), ".*");
-
// TODO(flowerhack): Once this is switched to the "real" implementation, make
// sure you can only mmap into offsets in the Init range.
}
TEST(SanitizerCommon, ReservedAddressRangeUnmap) {
uptr PageSize = GetPageSizeCached();
- uptr init_size = PageSize * 4;
+ uptr init_size = PageSize * 8;
ReservedAddressRange address_range;
uptr base_addr = address_range.Init(init_size);
CHECK_NE(base_addr, (void*)-1);
CHECK_EQ(base_addr, address_range.Map(base_addr, init_size));
// Unmapping the entire range should succeed.
- address_range.Unmap(base_addr, PageSize * 4);
+ address_range.Unmap(base_addr, init_size);
- // Remap that range in.
+ // Map a new range.
+ base_addr = address_range.Init(init_size);
CHECK_EQ(base_addr, address_range.Map(base_addr, init_size));
// Windows doesn't allow partial unmappings.
@@ -384,7 +382,7 @@ TEST(SanitizerCommon, ReservedAddressRangeUnmap) {
#endif
// Unmapping in the middle of the ReservedAddressRange should fail.
- EXPECT_DEATH(address_range.Unmap(base_addr + 0xf, 0xff), ".*");
+ EXPECT_DEATH(address_range.Unmap(base_addr + (PageSize * 2), PageSize), ".*");
}
} // namespace __sanitizer