Index: lib/sanitizer_common/sanitizer_allocator.h =================================================================== --- lib/sanitizer_common/sanitizer_allocator.h +++ lib/sanitizer_common/sanitizer_allocator.h @@ -421,7 +421,8 @@ // Test-only. void TestOnlyUnmap() { - UnmapWithCallback(SpaceBeg(), kSpaceSize + AdditionalSize()); + UnmapWithCallback(SpaceBeg(), kSpaceSize); + UnmapWithCallback(SpaceEnd(), AdditionalSize()); } void PrintStats() { Index: lib/sanitizer_common/sanitizer_win.cc =================================================================== --- lib/sanitizer_common/sanitizer_win.cc +++ lib/sanitizer_common/sanitizer_win.cc @@ -183,7 +183,10 @@ void *MmapFixedOrDie(uptr fixed_addr, uptr size) { void *p = VirtualAlloc((LPVOID)fixed_addr, size, - MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + MEM_COMMIT, PAGE_READWRITE); + if (p == 0) + p = VirtualAlloc((LPVOID)fixed_addr, size, + MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); if (p == 0) { char mem_type[30]; internal_snprintf(mem_type, sizeof(mem_type), "memory at address 0x%zx", @@ -201,7 +204,7 @@ void *MmapFixedNoAccess(uptr fixed_addr, uptr size, const char *name) { (void)name; // unsupported void *res = VirtualAlloc((LPVOID)fixed_addr, size, - MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS); + MEM_RESERVE, PAGE_NOACCESS); if (res == 0) Report("WARNING: %s failed to " "mprotect %p (%zd) bytes at %p (error code: %d)\n", Index: lib/sanitizer_common/tests/sanitizer_allocator_test.cc =================================================================== --- lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ lib/sanitizer_common/tests/sanitizer_allocator_test.cc @@ -29,9 +29,9 @@ #if !SANITIZER_DEBUG #if SANITIZER_CAN_USE_ALLOCATOR64 -static const uptr kAllocatorSpace = 0x700000000000ULL; -static const uptr kAllocatorSize = 0x010000000000ULL; // 1T. -static const u64 kAddressSpaceSize = 1ULL << 47; +static const uptr kAllocatorSpace = 0x10000000000ULL; +static const uptr kAllocatorSize = 0x10000000000ULL; // 1T. +static const u64 kAddressSpaceSize = 1ULL << 40; typedef SizeClassAllocator64< kAllocatorSpace, kAllocatorSize, 16, DefaultSizeClassMap> Allocator64; @@ -235,10 +235,12 @@ TEST(SanitizerCommon, SizeClassAllocator64CompactGetBlockBegin) { SizeClassAllocatorGetBlockBeginStress(); } +#endif // SANITIZER_CAN_USE_ALLOCATOR64 + TEST(SanitizerCommon, SizeClassAllocator32CompactGetBlockBegin) { SizeClassAllocatorGetBlockBeginStress(); } -#endif // SANITIZER_CAN_USE_ALLOCATOR64 + struct TestMapUnmapCallback { static int map_count, unmap_count; @@ -266,7 +268,8 @@ a->AllocateBatch(&stats, &cache, 32); EXPECT_EQ(TestMapUnmapCallback::map_count, 3); // State + alloc + metadata. a->TestOnlyUnmap(); - EXPECT_EQ(TestMapUnmapCallback::unmap_count, 1); // The whole thing. + // Expect unmapping of 'memory space' and 'additional memory'. + EXPECT_EQ(TestMapUnmapCallback::unmap_count, 2); delete a; } #endif