diff options
author | Alex Shlyapnikov <alekseys@google.com> | 2018-06-08 20:40:35 +0000 |
---|---|---|
committer | Alex Shlyapnikov <alekseys@google.com> | 2018-06-08 20:40:35 +0000 |
commit | 77b27c99d38c3a0905272ea8a2b133b6c77b300c (patch) | |
tree | 4d95f18732d07c339f33b6c0074621442cd44478 /test/lsan | |
parent | 8c252bbd0b5829284775ce609670a8f3de464a2c (diff) |
[Sanitizers] Check alignment != 0 for aligned_alloc and posix_memalign
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.
Reviewers: vitalybuka
Subscribers: srhines, kubamracek, delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D47924
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@334316 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/lsan')
-rw-r--r-- | test/lsan/TestCases/Linux/aligned_alloc-alignment.cc | 25 | ||||
-rw-r--r-- | test/lsan/TestCases/Posix/posix_memalign-alignment.cc | 22 |
2 files changed, 0 insertions, 47 deletions
diff --git a/test/lsan/TestCases/Linux/aligned_alloc-alignment.cc b/test/lsan/TestCases/Linux/aligned_alloc-alignment.cc deleted file mode 100644 index 370691d58..000000000 --- a/test/lsan/TestCases/Linux/aligned_alloc-alignment.cc +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clangxx_lsan -O0 %s -o %t -// RUN: %env_lsan_opts=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s -// RUN: %env_lsan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL - -// UNSUPPORTED: android - -// REQUIRES: stable-runtime - -#include <stdio.h> -#include <stdlib.h> - -extern void *aligned_alloc(size_t alignment, size_t size); - -int main() { - void *p = aligned_alloc(17, 100); - // CHECK: {{ERROR: .*Sanitizer: invalid allocation alignment: 17}} - // CHECK: {{#0 0x.* in .*}}{{aligned_alloc|memalign}} - // CHECK: {{#1 0x.* in main .*aligned_alloc-alignment.cc:}}[[@LINE-3]] - // CHECK: {{SUMMARY: .*Sanitizer: invalid-allocation-alignment}} - - printf("pointer after failed aligned_alloc: %zd\n", (size_t)p); - // CHECK-NULL: pointer after failed aligned_alloc: 0 - - return 0; -} diff --git a/test/lsan/TestCases/Posix/posix_memalign-alignment.cc b/test/lsan/TestCases/Posix/posix_memalign-alignment.cc deleted file mode 100644 index 1b9b14ebe..000000000 --- a/test/lsan/TestCases/Posix/posix_memalign-alignment.cc +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clangxx_lsan -O0 %s -o %t -// RUN: %env_lsan_opts=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s -// RUN: %env_lsan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL - -// REQUIRES: stable-runtime - -#include <stdio.h> -#include <stdlib.h> - -int main() { - void *p = reinterpret_cast<void*>(42); - int res = posix_memalign(&p, 17, 100); - // CHECK: {{ERROR: .*Sanitizer: invalid alignment requested in posix_memalign: 17}} - // CHECK: {{#0 0x.* in .*posix_memalign}} - // CHECK: {{#1 0x.* in main .*posix_memalign-alignment.cc:}}[[@LINE-3]] - // CHECK: {{SUMMARY: .*Sanitizer: invalid-posix-memalign-alignment}} - - printf("pointer after failed posix_memalign: %zd\n", (size_t)p); - // CHECK-NULL: pointer after failed posix_memalign: 42 - - return 0; -} |