]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/double-free.cc
1 // RUN: %clangxx_asan -O0 %s -o %t 2>&1
2 // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=MALLOC-CTX
4 // Also works if no malloc context is available.
5 // RUN: %env_asan_opts=malloc_context_size=0:fast_unwind_on_malloc=0 not %run %t 2>&1 | FileCheck %s
6 // RUN: %env_asan_opts=malloc_context_size=0:fast_unwind_on_malloc=1 not %run %t 2>&1 | FileCheck %s
7 // XFAIL: arm-linux-gnueabi
8 // XFAIL: armv7l-unknown-linux-gnueabihf
12 int main(int argc
, char **argv
) {
13 char *x
= (char*)malloc(10 * sizeof(char));
17 free(x
+ argc
- 1); // BOOM
18 // CHECK: AddressSanitizer: attempting double-free{{.*}}in thread T0
19 // CHECK: #0 0x{{.*}} in {{.*}}free
20 // CHECK: #1 0x{{.*}} in main {{.*}}double-free.cc:[[@LINE-3]]
21 // CHECK: freed by thread T0 here:
22 // MALLOC-CTX: #0 0x{{.*}} in {{.*}}free
23 // MALLOC-CTX: #1 0x{{.*}} in main {{.*}}double-free.cc:[[@LINE-7]]
24 // CHECK: allocated by thread T0 here:
25 // MALLOC-CTX: double-free.cc:[[@LINE-12]]