Alexey Samsonov | 4b9f050 | 2013-11-05 23:29:12 +0000 | [diff] [blame] | 1 | // RUN: %clangxx_asan -O0 %s -o %t |
Alexander Potapenko | 7d4a955 | 2013-11-06 14:00:37 +0000 | [diff] [blame^] | 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 |
Alexey Samsonov | 4b9f050 | 2013-11-05 23:29:12 +0000 | [diff] [blame] | 6 | |
| 7 | int main() { |
| 8 | char *x = new char[20]; |
| 9 | delete[] x; |
| 10 | return x[0]; |
Alexander Potapenko | 7d4a955 | 2013-11-06 14:00:37 +0000 | [diff] [blame^] | 11 | // 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 Samsonov | 4b9f050 | 2013-11-05 23:29:12 +0000 | [diff] [blame] | 18 | // CHECK-NOT: #1 0x{{.*}} |
Alexander Potapenko | 7d4a955 | 2013-11-06 14:00:37 +0000 | [diff] [blame^] | 19 | |
| 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 Samsonov | 4b9f050 | 2013-11-05 23:29:12 +0000 | [diff] [blame] | 24 | // CHECK-NOT: #1 0x{{.*}} |
| 25 | |
| 26 | // CHECK: SUMMARY: AddressSanitizer: heap-use-after-free |
| 27 | } |