diff options
Diffstat (limited to 'compiler-rt/lib/msan/msan_allocator.cpp')
| -rw-r--r-- | compiler-rt/lib/msan/msan_allocator.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler-rt/lib/msan/msan_allocator.cpp b/compiler-rt/lib/msan/msan_allocator.cpp index 6aa4e2738075..a08c1a00d2e5 100644 --- a/compiler-rt/lib/msan/msan_allocator.cpp +++ b/compiler-rt/lib/msan/msan_allocator.cpp @@ -115,9 +115,16 @@ static Allocator allocator; static AllocatorCache fallback_allocator_cache; static StaticSpinMutex fallback_mutex; +static uptr max_malloc_size; + void MsanAllocatorInit() { SetAllocatorMayReturnNull(common_flags()->allocator_may_return_null); allocator.Init(common_flags()->allocator_release_to_os_interval_ms); + if (common_flags()->max_allocation_size_mb) + max_malloc_size = Min(common_flags()->max_allocation_size_mb << 20, + kMaxAllowedMallocSize); + else + max_malloc_size = kMaxAllowedMallocSize; } AllocatorCache *GetAllocatorCache(MsanThreadLocalMallocStorage *ms) { @@ -132,12 +139,12 @@ void MsanThreadLocalMallocStorage::CommitBack() { static void *MsanAllocate(StackTrace *stack, uptr size, uptr alignment, bool zeroise) { - if (size > kMaxAllowedMallocSize) { + if (size > max_malloc_size) { if (AllocatorMayReturnNull()) { Report("WARNING: MemorySanitizer failed to allocate 0x%zx bytes\n", size); return nullptr; } - ReportAllocationSizeTooBig(size, kMaxAllowedMallocSize, stack); + ReportAllocationSizeTooBig(size, max_malloc_size, stack); } MsanThread *t = GetCurrentThread(); void *allocated; |
