diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2019-02-15 18:38:14 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2019-02-15 18:38:14 +0000 |
commit | 8f60425d39240ec5e4677d5378d2d7ca5b8a4269 (patch) | |
tree | efc59317b8cba3ae422ddae3c792a73542ecaca8 /test/hwasan | |
parent | f7986b4647ca061257cf9fa9b456d64a2dd9e7d2 (diff) | |
download | compiler-rt-8f60425d39240ec5e4677d5378d2d7ca5b8a4269.tar.gz |
Runtime flags for malloc bisection.
Reviewers: kcc, pcc
Subscribers: kubamracek, mgorny, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D58162
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354156 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/hwasan')
-rw-r--r-- | test/hwasan/TestCases/malloc_bisect.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/hwasan/TestCases/malloc_bisect.c b/test/hwasan/TestCases/malloc_bisect.c new file mode 100644 index 000000000..51cbbfe2a --- /dev/null +++ b/test/hwasan/TestCases/malloc_bisect.c @@ -0,0 +1,26 @@ +// RUN: %clang_hwasan -O0 %s -o %t +// RUN: %env_hwasan_opts=malloc_bisect_left=0,malloc_bisect_right=0 not %run %t 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CRASH +// RUN: %env_hwasan_opts=malloc_bisect_left=1000,malloc_bisect_right=999 %run %t 2>&1 +// RUN: %env_hwasan_opts=malloc_bisect_left=0,malloc_bisect_right=4294967295 not %run %t 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CRASH +// RUN: %env_hwasan_opts=malloc_bisect_left=0,malloc_bisect_right=4294967295,malloc_bisect_dump=1 not %run %t 2>&1 | \ +// RUN: FileCheck %s --check-prefixes=CRASH,DUMP + +#include <stdlib.h> +#include <stdio.h> +#include <sanitizer/hwasan_interface.h> + +int main() { + __hwasan_enable_allocator_tagging(); + // DUMP: [alloc] {{.*}} 10{{$}} + // DUMP: in main{{.*}}malloc_bisect.c + char * volatile p = (char*)malloc(10); + // CRASH: HWAddressSanitizer: tag-mismatch on address + // CRASH: in main{{.*}}malloc_bisect.c + char volatile x = p[16]; + free(p); + __hwasan_disable_allocator_tagging(); + + return 0; +} |