From e3fe203ec7f766ad6028144d266557b0d89b77fe Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Wed, 16 Sep 2020 13:48:19 -0700 Subject: [PATCH] Revert "[lsan] Share platform allocator settings between ASan and LSan" This reverts commit c57df3dc09e8b59c55c83ba5c354569a82a5c3b8 which broke Windows sanitizer bots. --- compiler-rt/lib/asan/asan_allocator.h | 38 +++++++++++++-- compiler-rt/lib/lsan/lsan_allocator.h | 47 ++++++++++++------- .../sanitizer_common/sanitizer_allocator.h | 37 --------------- 3 files changed, 65 insertions(+), 57 deletions(-) diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h index 4d4a7f1b135c..612799f90964 100644 --- a/compiler-rt/lib/asan/asan_allocator.h +++ b/compiler-rt/lib/asan/asan_allocator.h @@ -118,13 +118,43 @@ struct AsanMapUnmapCallback { void OnUnmap(uptr p, uptr size) const; }; -using SizeClassMap = __sanitizer::AllocatorSizeClassMap; - #if SANITIZER_CAN_USE_ALLOCATOR64 +# if SANITIZER_FUCHSIA +const uptr kAllocatorSpace = ~(uptr)0; +const uptr kAllocatorSize = 0x40000000000ULL; // 4T. +typedef DefaultSizeClassMap SizeClassMap; +# elif defined(__powerpc64__) +const uptr kAllocatorSpace = ~(uptr)0; +const uptr kAllocatorSize = 0x20000000000ULL; // 2T. +typedef DefaultSizeClassMap SizeClassMap; +# elif defined(__aarch64__) && SANITIZER_ANDROID +// Android needs to support 39, 42 and 48 bit VMA. +const uptr kAllocatorSpace = ~(uptr)0; +const uptr kAllocatorSize = 0x2000000000ULL; // 128G. +typedef VeryCompactSizeClassMap SizeClassMap; +# elif defined(__aarch64__) +// AArch64/SANITIZER_CAN_USE_ALLOCATOR64 is only for 42-bit VMA +// so no need to different values for different VMA. +const uptr kAllocatorSpace = 0x10000000000ULL; +const uptr kAllocatorSize = 0x10000000000ULL; // 3T. +typedef DefaultSizeClassMap SizeClassMap; +#elif defined(__sparc__) +const uptr kAllocatorSpace = ~(uptr)0; +const uptr kAllocatorSize = 0x20000000000ULL; // 2T. +typedef DefaultSizeClassMap SizeClassMap; +# elif SANITIZER_WINDOWS +const uptr kAllocatorSpace = ~(uptr)0; +const uptr kAllocatorSize = 0x8000000000ULL; // 500G +typedef DefaultSizeClassMap SizeClassMap; +# else +const uptr kAllocatorSpace = 0x600000000000ULL; +const uptr kAllocatorSize = 0x40000000000ULL; // 4T. +typedef DefaultSizeClassMap SizeClassMap; +# endif template struct AP64 { // Allocator64 parameters. Deliberately using a short name. - static const uptr kSpaceBeg = __sanitizer::kAllocatorSpace; - static const uptr kSpaceSize = __sanitizer::kAllocatorSize; + static const uptr kSpaceBeg = kAllocatorSpace; + static const uptr kSpaceSize = kAllocatorSize; static const uptr kMetadataSize = 0; typedef __asan::SizeClassMap SizeClassMap; typedef AsanMapUnmapCallback MapUnmapCallback; diff --git a/compiler-rt/lib/lsan/lsan_allocator.h b/compiler-rt/lib/lsan/lsan_allocator.h index b820dd15ecdb..17e13cd014ba 100644 --- a/compiler-rt/lib/lsan/lsan_allocator.h +++ b/compiler-rt/lib/lsan/lsan_allocator.h @@ -49,21 +49,8 @@ struct ChunkMetadata { u32 stack_trace_id; }; -#if SANITIZER_CAN_USE_ALLOCATOR64 -template -struct AP64 { // Allocator64 parameters. Deliberately using a short name. - static const uptr kSpaceBeg = __sanitizer::kAllocatorSpace; - static const uptr kSpaceSize = __sanitizer::kAllocatorSize; - static const uptr kMetadataSize = sizeof(ChunkMetadata); - typedef __sanitizer::AllocatorSizeClassMap SizeClassMap; - typedef NoOpMapUnmapCallback MapUnmapCallback; - static const uptr kFlags = 0; - using AddressSpaceView = AddressSpaceViewTy; -}; -template -using PrimaryAllocatorASVT = SizeClassAllocator64>; -using PrimaryAllocator = PrimaryAllocatorASVT; -#else // !SANITIZER_CAN_USE_ALLOCATOR64 +#if defined(__mips64) || defined(__aarch64__) || defined(__i386__) || \ + defined(__arm__) template struct AP32 { static const uptr kSpaceBeg = 0; @@ -78,7 +65,35 @@ struct AP32 { template using PrimaryAllocatorASVT = SizeClassAllocator32>; using PrimaryAllocator = PrimaryAllocatorASVT; -#endif // SANITIZER_CAN_USE_ALLOCATOR64 +#elif defined(__x86_64__) || defined(__powerpc64__) || defined(__s390x__) +# if SANITIZER_FUCHSIA +const uptr kAllocatorSpace = ~(uptr)0; +const uptr kAllocatorSize = 0x40000000000ULL; // 4T. +# elif defined(__powerpc64__) +const uptr kAllocatorSpace = 0xa0000000000ULL; +const uptr kAllocatorSize = 0x20000000000ULL; // 2T. +#elif defined(__s390x__) +const uptr kAllocatorSpace = 0x40000000000ULL; +const uptr kAllocatorSize = 0x40000000000ULL; // 4T. +# else +const uptr kAllocatorSpace = 0x600000000000ULL; +const uptr kAllocatorSize = 0x40000000000ULL; // 4T. +# endif +template +struct AP64 { // Allocator64 parameters. Deliberately using a short name. + static const uptr kSpaceBeg = kAllocatorSpace; + static const uptr kSpaceSize = kAllocatorSize; + static const uptr kMetadataSize = sizeof(ChunkMetadata); + typedef DefaultSizeClassMap SizeClassMap; + typedef NoOpMapUnmapCallback MapUnmapCallback; + static const uptr kFlags = 0; + using AddressSpaceView = AddressSpaceViewTy; +}; + +template +using PrimaryAllocatorASVT = SizeClassAllocator64>; +using PrimaryAllocator = PrimaryAllocatorASVT; +#endif template using AllocatorASVT = CombinedAllocator>; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h index dd792de1effa..23d589888d3b 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h @@ -76,43 +76,6 @@ INLINE void RandomShuffle(T *a, u32 n, u32 *rand_state) { #include "sanitizer_allocator_secondary.h" #include "sanitizer_allocator_combined.h" -// The platform-specific default parameters are shared by both -// asan_allocator.h and lsan_allocator.h. -#if SANITIZER_CAN_USE_ALLOCATOR64 -# if SANITIZER_FUCHSIA -const uptr kAllocatorSpace = ~(uptr)0; -const uptr kAllocatorSize = 0x40000000000ULL; // 4T. -using AllocatorSizeClassMap = DefaultSizeClassMap; -# elif defined(__powerpc64__) -const uptr kAllocatorSpace = ~(uptr)0; -const uptr kAllocatorSize = 0x20000000000ULL; // 2T. -using AllocatorSizeClassMap = DefaultSizeClassMap; -# elif defined(__aarch64__) && SANITIZER_ANDROID -// Android needs to support 39, 42 and 48 bit VMA. -const uptr kAllocatorSpace = ~(uptr)0; -const uptr kAllocatorSize = 0x2000000000ULL; // 128G. -using AllocatorSizeClassMap = VeryCompactSizeClassMap; -# elif defined(__aarch64__) -// AArch64/SANITIZER_CAN_USE_ALLOCATOR64 is only for 42-bit VMA -// so no need to different values for different VMA. -const uptr kAllocatorSpace = 0x10000000000ULL; -const uptr kAllocatorSize = 0x10000000000ULL; // 3T. -using AllocatorSizeClassMap = DefaultSizeClassMap; -#elif defined(__sparc__) -const uptr kAllocatorSpace = ~(uptr)0; -const uptr kAllocatorSize = 0x20000000000ULL; // 2T. -using AllocatorSizeClassMap = DefaultSizeClassMap; -# elif SANITIZER_WINDOWS -const uptr kAllocatorSpace = ~(uptr)0; -const uptr kAllocatorSize = 0x8000000000ULL; // 500G -using AllocatorSizeClassMap = DefaultSizeClassMap; -# else -const uptr kAllocatorSpace = 0x600000000000ULL; -const uptr kAllocatorSize = 0x40000000000ULL; // 4T. -using AllocatorSizeClassMap = DefaultSizeClassMap; -# endif -#endif // SANITIZER_CAN_USE_ALLOCATOR64 - } // namespace __sanitizer #endif // SANITIZER_ALLOCATOR_H