[PATCH] D35275: [Sanitizers] ASan/MSan/LSan allocators set errno on failure.

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 16:48:00 PDT 2017


vitalybuka added inline comments.


================
Comment at: lib/msan/msan_allocator.cc:269
+void *msan_aligned_alloc(uptr alignment, uptr size, StackTrace *stack) {
+  if (UNLIKELY(!IsPowerOfTwo(alignment) || (size & (alignment - 1)) != 0)) {
+    errno = errno_EINVAL;
----------------
why not just (size % alignmet == 0) and ignore "power of two" check?


================
Comment at: lib/msan/msan_allocator.cc:287
+  if (UNLIKELY(!IsPowerOfTwo(alignment) ||
+               (alignment % sizeof(void *)) != 0)) {  // NOLINT
+    Allocator::FailureHandler::OnBadRequest();
----------------
maybe just, pointer should be always power of two?
if (UNLIKELY((alignment % sizeof(void *)))) { 




https://reviews.llvm.org/D35275





More information about the llvm-commits mailing list