blob: c753a3a5d2b597a30be2f8b0bef6827d07fdfc46 [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001// RUN: %clangxx_asan -O0 %s -o %t
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08002// RUN: %env_asan_opts=malloc_context_size=0:fast_unwind_on_malloc=0 not %run %t 2>&1 | FileCheck %s
3// RUN: %env_asan_opts=malloc_context_size=0:fast_unwind_on_malloc=1 not %run %t 2>&1 | FileCheck %s
4// RUN: %env_asan_opts=malloc_context_size=1:fast_unwind_on_malloc=0 not %run %t 2>&1 | FileCheck %s
5// RUN: %env_asan_opts=malloc_context_size=1:fast_unwind_on_malloc=1 not %run %t 2>&1 | FileCheck %s
6// RUN: %env_asan_opts=malloc_context_size=2 not %run %t 2>&1 | FileCheck %s --check-prefix=TWO
Stephen Hines2d1fdb22014-05-28 23:58:16 -07007
8int main() {
9 char *x = new char[20];
10 delete[] x;
11 return x[0];
Stephen Hines2d1fdb22014-05-28 23:58:16 -070012
Stephen Hines6d186232014-11-26 17:56:19 -080013 // CHECK: freed by thread T{{.*}} here:
14 // CHECK-NEXT: #0 0x{{.*}} in {{operator delete( )?\[\]|wrap__ZdaPv}}
Stephen Hines2d1fdb22014-05-28 23:58:16 -070015 // CHECK-NOT: #1 0x{{.*}}
16
Stephen Hines6d186232014-11-26 17:56:19 -080017 // CHECK: previously allocated by thread T{{.*}} here:
18 // CHECK-NEXT: #0 0x{{.*}} in {{operator new( )?\[\]|wrap__Znam}}
Stephen Hines2d1fdb22014-05-28 23:58:16 -070019 // CHECK-NOT: #1 0x{{.*}}
20
21 // CHECK: SUMMARY: AddressSanitizer: heap-use-after-free
22
23 // TWO: previously allocated by thread T{{.*}} here:
24 // TWO-NEXT: #0 0x{{.*}}
25 // TWO-NEXT: #1 0x{{.*}} in main {{.*}}malloc_context_size.cc
26 // TWO: SUMMARY: AddressSanitizer: heap-use-after-free
27}