blob: 266ce66f59e208de58f03c744a7cd5f66f6228d5 [file] [log] [blame]
Alexey Samsonov4b9f0502013-11-05 23:29:12 +00001// RUN: %clangxx_asan -O0 %s -o %t
Alexander Potapenko7d4a9552013-11-06 14:00:37 +00002// 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
Alexey Samsonov4b9f0502013-11-05 23:29:12 +00006
7int main() {
8 char *x = new char[20];
9 delete[] x;
10 return x[0];
Alexander Potapenko7d4a9552013-11-06 14:00:37 +000011 // We need to keep duplicate lines with different 'CHECK-%os' prefixes,
12 // otherwise FileCheck barks on missing 'CHECK-%os' before 'CHECK-%os-NEXT'.
13
14 // CHECK-Linux: freed by thread T{{.*}} here:
15 // CHECK-Linux-NEXT: #0 0x{{.*}} in operator delete[]
16 // CHECK-Darwin: freed by thread T{{.*}} here:
17 // CHECK-Darwin-NEXT: #0 0x{{.*}} in wrap__ZdaPv
Alexey Samsonov4b9f0502013-11-05 23:29:12 +000018 // CHECK-NOT: #1 0x{{.*}}
Alexander Potapenko7d4a9552013-11-06 14:00:37 +000019
20 // CHECK-Linux: previously allocated by thread T{{.*}} here:
21 // CHECK-Linux-NEXT: #0 0x{{.*}} in operator new[]
22 // CHECK-Darwin: previously allocated by thread T{{.*}} here:
23 // CHECK-Darwin-NEXT: #0 0x{{.*}} in wrap__Znam
Alexey Samsonov4b9f0502013-11-05 23:29:12 +000024 // CHECK-NOT: #1 0x{{.*}}
25
26 // CHECK: SUMMARY: AddressSanitizer: heap-use-after-free
27}