From bfeb7990b20c149e17ea88f463307c02b6e16534 Mon Sep 17 00:00:00 2001 From: Kostya Kortchinsky Date: Fri, 9 Dec 2016 03:28:12 +0000 Subject: [PATCH] Reverting rL289088 while investigating some test issue on the build servers Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D27605 llvm-svn: 289180 --- .../lib/sanitizer_common/sanitizer_allocator_combined.h | 15 +-------------- compiler-rt/lib/scudo/scudo_allocator_secondary.h | 7 +++---- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h index a6d0864..de96e27 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h @@ -49,29 +49,16 @@ class CombinedAllocator { size = 1; if (size + alignment < size) return ReturnNullOrDieOnBadRequest(); if (check_rss_limit && RssLimitIsExceeded()) return ReturnNullOrDieOnOOM(); - uptr original_size = size; - // If alignment requirements are to be fulfilled by the frontend allocator - // rather than by the primary or secondary, passing an alignment lower than - // or equal to 8 will prevent any further rounding up, as well as the later - // alignment check. if (alignment > 8) size = RoundUpTo(size, alignment); void *res; bool from_primary = primary_.CanAllocate(size, alignment); - // The primary allocator should return a 2^x aligned allocation when - // requested 2^x bytes, hence using the rounded up 'size' when being - // serviced by the primary. The secondary takes care of the alignment - // without such requirement, and allocating 'size' would use extraneous - // memory, so we employ 'original_size'. if (from_primary) res = cache->Allocate(&primary_, primary_.ClassID(size)); else - res = secondary_.Allocate(&stats_, original_size, alignment); + res = secondary_.Allocate(&stats_, size, alignment); if (alignment > 8) CHECK_EQ(reinterpret_cast(res) & (alignment - 1), 0); - // When serviced by the secondary, the chunk comes from a mmap allocation - // and will be zero'd out anyway. We only need to clear our the chunk if - // it was serviced by the primary, hence using the rounded up 'size'. if (cleared && res && from_primary) internal_bzero_aligned16(res, RoundUpTo(size, 16)); return res; diff --git a/compiler-rt/lib/scudo/scudo_allocator_secondary.h b/compiler-rt/lib/scudo/scudo_allocator_secondary.h index 3b247bf..d3468f8 100644 --- a/compiler-rt/lib/scudo/scudo_allocator_secondary.h +++ b/compiler-rt/lib/scudo/scudo_allocator_secondary.h @@ -54,9 +54,8 @@ class ScudoLargeMmapAllocator { uptr NewMapBeg = UserBeg - HeadersSize; NewMapBeg = RoundDownTo(NewMapBeg, PageSize) - PageSize; CHECK_GE(NewMapBeg, MapBeg); - uptr NewMapEnd = - RoundUpTo(UserBeg + Size - Alignment - AlignedChunkHeaderSize, - PageSize) + PageSize; + uptr NewMapSize = RoundUpTo(MapSize - Alignment, PageSize); + uptr NewMapEnd = NewMapBeg + NewMapSize; CHECK_LE(NewMapEnd, MapEnd); // Unmap the extra memory if it's large enough. uptr Diff = NewMapBeg - MapBeg; @@ -66,8 +65,8 @@ class ScudoLargeMmapAllocator { if (Diff > PageSize) UnmapOrDie(reinterpret_cast(NewMapEnd), Diff); MapBeg = NewMapBeg; + MapSize = NewMapSize; MapEnd = NewMapEnd; - MapSize = NewMapEnd - NewMapBeg; } uptr UserEnd = UserBeg - AlignedChunkHeaderSize + Size; // For larger alignments, Alignment was added by the frontend to Size. -- 2.7.4