summaryrefslogtreecommitdiff
path: root/lib/asan/lit_tests/TestCases/malloc_context_size.cc
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-11-05 23:29:12 +0000
committerAlexey Samsonov <samsonov@google.com>2013-11-05 23:29:12 +0000
commit4b9f050c2acab536356342ab96e6cc76c281ac24 (patch)
tree555a6b13e1541e05d0937598b30ccab3724d2b4d /lib/asan/lit_tests/TestCases/malloc_context_size.cc
parent4197fa23ada9682343a15b68dde08c0249db172a (diff)
downloadcompiler-rt-4b9f050c2acab536356342ab96e6cc76c281ac24.tar.gz
compiler-rt-4b9f050c2acab536356342ab96e6cc76c281ac24.tar.bz2
compiler-rt-4b9f050c2acab536356342ab96e6cc76c281ac24.tar.xz
[ASan] Make sure slow stack unwinder doesn't return empty stacks.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194107 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/lit_tests/TestCases/malloc_context_size.cc')
-rw-r--r--lib/asan/lit_tests/TestCases/malloc_context_size.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/asan/lit_tests/TestCases/malloc_context_size.cc b/lib/asan/lit_tests/TestCases/malloc_context_size.cc
new file mode 100644
index 00000000..7449dbe2
--- /dev/null
+++ b/lib/asan/lit_tests/TestCases/malloc_context_size.cc
@@ -0,0 +1,19 @@
+// RUN: %clangxx_asan -O0 %s -o %t
+// RUN: ASAN_OPTIONS=malloc_context_size=0:fast_unwind_on_malloc=0 not %t 2>&1 | FileCheck %s
+// RUN: ASAN_OPTIONS=malloc_context_size=0:fast_unwind_on_malloc=1 not %t 2>&1 | FileCheck %s
+// RUN: ASAN_OPTIONS=malloc_context_size=1:fast_unwind_on_malloc=0 not %t 2>&1 | FileCheck %s
+// RUN: ASAN_OPTIONS=malloc_context_size=1:fast_unwind_on_malloc=1 not %t 2>&1 | FileCheck %s
+
+int main() {
+ char *x = new char[20];
+ delete[] x;
+ return x[0];
+ // CHECK: freed by thread T{{.*}} here:
+ // CHECK-NEXT: #0 0x{{.*}} in operator delete[]
+ // CHECK-NOT: #1 0x{{.*}}
+ // CHECK: previously allocated by thread T{{.*}} here:
+ // CHECK-NEXT: #0 0x{{.*}} in operator new[]
+ // CHECK-NOT: #1 0x{{.*}}
+
+ // CHECK: SUMMARY: AddressSanitizer: heap-use-after-free
+}