forked from OSchip/llvm-project
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 llvm-svn: 316943
This commit is contained in:
parent
c18d5c05cb
commit
264e1b73eb
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue