[compiler-rt] r316943 - Fix warning + death test + failing test on Windows (D39072).
Kostya Kortchinsky via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 30 12:06:59 PDT 2017
Author: cryptoad
Date: Mon Oct 30 12:06:59 2017
New Revision: 316943
URL: http://llvm.org/viewvc/llvm-project?rev=316943&view=rev
Log:
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
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=316943&r1=316942&r2=316943&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Mon Oct 30 12:06:59 2017
@@ -249,8 +249,8 @@ void ReservedAddressRange::Unmap(uptr ad
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) {
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc?rev=316943&r1=316942&r2=316943&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc Mon Oct 30 12:06:59 2017
@@ -349,25 +349,23 @@ TEST(SanitizerCommon, ReservedAddressRan
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, ReservedAddressRan
#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
More information about the llvm-commits
mailing list