1 // RUN: %clangxx_asan -O0 %s -o %t 2>&1
2 // RUN: not %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=MALLOC-CTX
4 // Also works if no malloc context is available.
5 // RUN: ASAN_OPTIONS=malloc_context_size=0:fast_unwind_on_malloc=0 not %t 2>&1 | FileCheck %s
6 // RUN: ASAN_OPTIONS=malloc_context_size=0:fast_unwind_on_malloc=1 not %t 2>&1 | FileCheck %s
10 int main(int argc
, char **argv
) {
11 char *x
= (char*)malloc(10 * sizeof(char));
15 free(x
+ argc
- 1); // BOOM
16 // CHECK: AddressSanitizer: attempting double-free{{.*}}in thread T0
17 // CHECK: #0 0x{{.*}} in {{.*}}free
18 // CHECK: #1 0x{{.*}} in main {{.*}}double-free.cc:[[@LINE-3]]
19 // CHECK: freed by thread T0 here:
20 // MALLOC-CTX: #0 0x{{.*}} in {{.*}}free
21 // MALLOC-CTX: #1 0x{{.*}} in main {{.*}}double-free.cc:[[@LINE-7]]
22 // CHECK: allocated by thread T0 here:
23 // MALLOC-CTX: double-free.cc:[[@LINE-12]]