[PATCH] D27428: [sanitizer] Do not use the alignment-rounded-up size when using the secondary

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 6 09:45:32 PST 2016


cryptoad marked 2 inline comments as done.
cryptoad added inline comments.


================
Comment at: lib/sanitizer_common/sanitizer_allocator_combined.h:62
     if (alignment > 8)
       CHECK_EQ(reinterpret_cast<uptr>(res) & (alignment - 1), 0);
     if (cleared && res && from_primary)
----------------
alekseyshl wrote:
> Is it safe to run this CHECK now, when secondary is using non-adjusted allocation size? 
sanitizer_allocator_secondary.h [[ https://github.com/llvm-mirror/compiler-rt/blob/master/lib/sanitizer_common/sanitizer_allocator_secondary.h#L37 | adds ]] alignment to the size prior to allocation and align the result properly.
It also does a similar CHECK there.
Same with the Scudo allocator, but the job is split between the frontend and the secondary.
So the CHECK is still safe.


================
Comment at: lib/sanitizer_common/sanitizer_allocator_combined.h:64
     if (cleared && res && from_primary)
       internal_bzero_aligned16(res, RoundUpTo(size, 16));
     return res;
----------------
alekseyshl wrote:
> Same here, it tries to zero out the result up to the rounded up size, not the original size.
If the allocation comes from the secondary, it's mmap backed and it's zero'd out, and we don't need to clear the memory again.
We need to zero out only when it comes from the primary, which uses the rounded size rather than the original size for its allocation.


https://reviews.llvm.org/D27428





More information about the llvm-commits mailing list