Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | // RUN: %clangxx_asan -O0 %s -o %t |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 2 | // 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 Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 7 | |
| 8 | int main() { |
| 9 | char *x = new char[20]; |
| 10 | delete[] x; |
| 11 | return x[0]; |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 12 | |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 13 | // CHECK: freed by thread T{{.*}} here: |
| 14 | // CHECK-NEXT: #0 0x{{.*}} in {{operator delete( )?\[\]|wrap__ZdaPv}} |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 15 | // CHECK-NOT: #1 0x{{.*}} |
| 16 | |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 17 | // CHECK: previously allocated by thread T{{.*}} here: |
| 18 | // CHECK-NEXT: #0 0x{{.*}} in {{operator new( )?\[\]|wrap__Znam}} |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 19 | // 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 | } |