1// Test recovery mode.
2//
3// RUN: %clang_asan -fsanitize-recover=address %s -o %t
4//
5// RUN: env not %run %t 2>&1 | FileCheck %s
6// RUN: %env_asan_opts=halt_on_error=true not %run %t 2>&1 | FileCheck %s
7// RUN: %env_asan_opts=halt_on_error=false %run %t 2>&1 | FileCheck %s --check-prefix CHECK-RECOVER
8
9#include <string.h>
10
11volatile int ten = 10;
12
13int main() {
14 char x[10];
15 // CHECK: WRITE of size 11
16 // CHECK-RECOVER: WRITE of size 11
17 memset(s: x, c: 0, n: 11);
18 // CHECK-NOT: READ of size 1
19 // CHECK-RECOVER: READ of size 1
20 volatile int res = x[ten];
21 // CHECK-NOT: WRITE of size 1
22 // CHECK-RECOVER: WRITE of size 1
23 x[ten] = res + 3;
24 // CHECK-NOT: READ of size 1
25 // CHECK-RECOVER: READ of size 1
26 res = x[ten];
27 return 0;
28}
29
30

source code of compiler-rt/test/asan/TestCases/halt_on_error-1.c