Reduce sizes for non _LP64 and compiler checks so that the code compiles

(but it will not work, since there is not enough address space to implement
the shadow space required).
This commit is contained in:
christos 2018-06-27 15:57:20 +00:00
parent 3a31568ee3
commit ecf509af59
2 changed files with 12 additions and 0 deletions

View File

@ -26,7 +26,11 @@ namespace __lsan {
struct ChunkMetadata {
u8 allocated : 8; // Must be first.
ChunkTag tag : 2;
#ifdef _LP64
uptr requested_size : 54;
#else
uptr requested_size : 30;
#endif
u32 stack_trace_id;
};
@ -40,9 +44,15 @@ typedef SizeClassAllocator32<0, SANITIZER_MMAP_RANGE_SIZE,
sizeof(ChunkMetadata), SizeClassMap, kRegionSizeLog, ByteMap>
PrimaryAllocator;
#else
#if _LP64
static const uptr kMaxAllowedMallocSize = 8UL << 30;
static const uptr kAllocatorSpace = 0x600000000000ULL;
static const uptr kAllocatorSize = 0x40000000000ULL; // 4T.
#else
static const uptr kMaxAllowedMallocSize = 8UL << 20;
static const uptr kAllocatorSpace = 0x60000000UL;
static const uptr kAllocatorSize = 0x40000000ULL; // 2G.
#endif
typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize,
sizeof(ChunkMetadata), DefaultSizeClassMap> PrimaryAllocator;
#endif

View File

@ -475,9 +475,11 @@ class SizeClassAllocator64 {
private:
static const uptr kRegionSize = kSpaceSize / kNumClassesRounded;
static const uptr kSpaceEnd = kSpaceBeg + kSpaceSize;
#if _LP64
COMPILER_CHECK(kSpaceBeg % kSpaceSize == 0);
// kRegionSize must be >= 2^32.
COMPILER_CHECK((kRegionSize) >= (1ULL << (SANITIZER_WORDSIZE / 2)));
#endif
// Populate the free list with at most this number of bytes at once
// or with one element if its size is greater.
static const uptr kPopulateSize = 1 << 14;