1*673dc3d4SNico Weber // RUN: %clangxx_asan -O0 %s -o %t
2*673dc3d4SNico Weber // RUN: %env_asan_opts=malloc_context_size=0:fast_unwind_on_malloc=0 not %run %t 2>&1 | FileCheck %s
3*673dc3d4SNico Weber // RUN: %env_asan_opts=malloc_context_size=0:fast_unwind_on_malloc=1 not %run %t 2>&1 | FileCheck %s
4*673dc3d4SNico Weber // RUN: %env_asan_opts=malloc_context_size=1:fast_unwind_on_malloc=0 not %run %t 2>&1 | FileCheck %s
5*673dc3d4SNico Weber // RUN: %env_asan_opts=malloc_context_size=1:fast_unwind_on_malloc=1 not %run %t 2>&1 | FileCheck %s
6*673dc3d4SNico Weber // RUN: %env_asan_opts=malloc_context_size=2 not %run %t 2>&1 | FileCheck %s --check-prefix=TWO
7*673dc3d4SNico Weber
main()8*673dc3d4SNico Weber int main() {
9*673dc3d4SNico Weber char *x = new char[20];
10*673dc3d4SNico Weber delete[] x;
11*673dc3d4SNico Weber return x[0];
12*673dc3d4SNico Weber
13*673dc3d4SNico Weber // CHECK: freed by thread T{{.*}} here:
14*673dc3d4SNico Weber // CHECK-NEXT: #0 0x{{.*}} in {{operator delete( )?\[\]|wrap__ZdaPv}}
15*673dc3d4SNico Weber // CHECK-NOT: #1 0x{{.*}}
16*673dc3d4SNico Weber
17*673dc3d4SNico Weber // CHECK: previously allocated by thread T{{.*}} here:
18*673dc3d4SNico Weber // CHECK-NEXT: #0 0x{{.*}} in {{operator new( )?\[\]|wrap__Znam}}
19*673dc3d4SNico Weber // CHECK-NOT: #1 0x{{.*}}
20*673dc3d4SNico Weber
21*673dc3d4SNico Weber // CHECK: SUMMARY: AddressSanitizer: heap-use-after-free
22*673dc3d4SNico Weber
23*673dc3d4SNico Weber // TWO: previously allocated by thread T{{.*}} here:
24*673dc3d4SNico Weber // TWO-NEXT: #0 0x{{.*}}
25*673dc3d4SNico Weber // TWO-NEXT: #1 0x{{.*}} in main {{.*}}malloc_context_size.cpp
26*673dc3d4SNico Weber // TWO: SUMMARY: AddressSanitizer: heap-use-after-free
27*673dc3d4SNico Weber }
28