This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizers] Check alignment != 0 for aligned_alloc and posix_memalign
ClosedPublic

Authored by alekseyshl on Jun 7 2018, 7:17 PM.

Details

Summary

Move the corresponding tests to the common folder (as all of the
sanitizer allocators will support this feature soon) and add the checks
specific to aligned_alloc to ASan and LSan allocators.

Diff Detail

Repository
rL LLVM

Event Timeline

alekseyshl created this revision.Jun 7 2018, 7:17 PM
Herald added subscribers: Restricted Project, delcypher, kubamracek, srhines. · View Herald TranscriptJun 7 2018, 7:17 PM
vitalybuka accepted this revision.Jun 8 2018, 10:52 AM
vitalybuka added inline comments.
lib/asan/asan_allocator.cc
931 ↗(On Diff #150443)

Can you move tests in the one patch, and refactor this reports in the another?

lib/sanitizer_common/sanitizer_allocator_checks.h
47 ↗(On Diff #150443)

0 is not power of 2
so maybe fix IsPowerOfTwo, because now it rather IsTheLeastBitNotSet

This revision is now accepted and ready to land.Jun 8 2018, 10:52 AM
alekseyshl added inline comments.Jun 8 2018, 11:37 AM
lib/sanitizer_common/sanitizer_allocator_checks.h
47 ↗(On Diff #150443)

I thought about that, but it is used in many places where we already know that the argument is not 0. I do not want to impose the overhead on all its users.

This revision was automatically updated to reflect the committed changes.
compiler-rt/trunk/test/asan/TestCases/Posix/posix_memalign-alignment.cc