]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK |
2 | // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK | |
3 | // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK | |
4 | // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK | |
92a42be0 SL |
5 | // XFAIL: arm-linux-gnueabi |
6 | // XFAIL: armv7l-unknown-linux-gnueabihf | |
1a4d82fc JJ |
7 | |
8 | #include <stdlib.h> | |
9 | int main() { | |
10 | char *x = (char*)malloc(10 * sizeof(char)); | |
11 | free(x); | |
12 | return x[5]; | |
13 | // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}} | |
14 | // CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}} | |
15 | // CHECK: {{READ of size 1 at 0x.* thread T0}} | |
92a42be0 | 16 | // CHECK: {{ #0 0x.* in main .*use-after-free.cc:}}[[@LINE-4]] |
1a4d82fc JJ |
17 | // CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}} |
18 | // CHECK: {{freed by thread T0 here:}} | |
19 | ||
20 | // CHECK-Linux: {{ #0 0x.* in .*free}} | |
92a42be0 | 21 | // CHECK-Linux: {{ #1 0x.* in main .*use-after-free.cc:}}[[@LINE-10]] |
1a4d82fc JJ |
22 | |
23 | // CHECK-Darwin: {{ #0 0x.* in wrap_free}} | |
92a42be0 | 24 | // CHECK-Darwin: {{ #1 0x.* in main .*use-after-free.cc:}}[[@LINE-13]] |
1a4d82fc JJ |
25 | |
26 | // CHECK: {{previously allocated by thread T0 here:}} | |
27 | ||
28 | // CHECK-Linux: {{ #0 0x.* in .*malloc}} | |
92a42be0 | 29 | // CHECK-Linux: {{ #1 0x.* in main .*use-after-free.cc:}}[[@LINE-19]] |
1a4d82fc JJ |
30 | |
31 | // CHECK-Darwin: {{ #0 0x.* in wrap_malloc.*}} | |
92a42be0 | 32 | // CHECK-Darwin: {{ #1 0x.* in main .*use-after-free.cc:}}[[@LINE-22]] |
1a4d82fc JJ |
33 | // CHECK: Shadow byte legend (one shadow byte represents 8 application bytes): |
34 | // CHECK: Global redzone: | |
35 | // CHECK: ASan internal: | |
36 | } |