[asan] enable LeakSanitizer (LSan) by default in asan. This only affects Linux x86_64...
[blocksruntime.git] / test / asan / TestCases / malloc_context_size.cc
blob8831de22f30e4f7b627bd6c0fe6c1d90f89472c8
1 // RUN: %clangxx_asan -O0 %s -o %t
2 // RUN: ASAN_OPTIONS=malloc_context_size=0:fast_unwind_on_malloc=0 not %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os
3 // RUN: ASAN_OPTIONS=malloc_context_size=0:fast_unwind_on_malloc=1 not %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os
4 // RUN: ASAN_OPTIONS=malloc_context_size=1:fast_unwind_on_malloc=0 not %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os
5 // RUN: ASAN_OPTIONS=malloc_context_size=1:fast_unwind_on_malloc=1 not %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os
6 // RUN: ASAN_OPTIONS=malloc_context_size=2 not %t 2>&1 | FileCheck %s --check-prefix=TWO
8 int main() {
9 char *x = new char[20];
10 delete[] x;
11 return x[0];
12 // We need to keep duplicate lines with different 'CHECK-%os' prefixes,
13 // otherwise FileCheck barks on missing 'CHECK-%os' before 'CHECK-%os-NEXT'.
15 // CHECK-Linux: freed by thread T{{.*}} here:
16 // CHECK-Linux-NEXT: #0 0x{{.*}} in operator delete[]
17 // CHECK-Darwin: freed by thread T{{.*}} here:
18 // CHECK-Darwin-NEXT: #0 0x{{.*}} in wrap__ZdaPv
19 // CHECK-NOT: #1 0x{{.*}}
21 // CHECK-Linux: previously allocated by thread T{{.*}} here:
22 // CHECK-Linux-NEXT: #0 0x{{.*}} in operator new[]
23 // CHECK-Darwin: previously allocated by thread T{{.*}} here:
24 // CHECK-Darwin-NEXT: #0 0x{{.*}} in wrap__Znam
25 // CHECK-NOT: #1 0x{{.*}}
27 // CHECK: SUMMARY: AddressSanitizer: heap-use-after-free
29 // TWO: previously allocated by thread T{{.*}} here:
30 // TWO-NEXT: #0 0x{{.*}}
31 // TWO-NEXT: #1 0x{{.*}} in main {{.*}}malloc_context_size.cc
32 // TWO: SUMMARY: AddressSanitizer: heap-use-after-free