1// Test reports dedupication for recovery mode.
2//
3// RUN: %clang_asan -fsanitize-recover=address %s -o %t
4//
5// Check for reports dedupication.
6// RUN: %env_asan_opts=halt_on_error=false %run %t 2>&1 | FileCheck %s
7//
8// Check that we die after reaching different reports number threshold.
9// RUN: %env_asan_opts=halt_on_error=false not %run %t 1 >%t1.log 2>&1
10// RUN: grep 'ERROR: AddressSanitizer: stack-buffer-overflow' %t1.log | count 25
11//
12// Check suppress_equal_pcs=true behavior is equal to default one.
13// RUN: %env_asan_opts=halt_on_error=false:suppress_equal_pcs=true %run %t 2>&1 | FileCheck %s
14//
15// Check suppress_equal_pcs=false behavior isn't equal to default one.
16// RUN: rm -f %t2.log
17// RUN: %env_asan_opts=halt_on_error=false:suppress_equal_pcs=false %run %t >%t2.log 2>&1
18// RUN: grep 'ERROR: AddressSanitizer: stack-buffer-overflow' %t2.log | count 30
19
20#define ACCESS_ARRAY_FIVE_ELEMENTS(array, i) \
21 array[i] = i; \
22 array[i + 1] = i + 1; \
23 array[i + 2] = i + 2; \
24 array[i + 3] = i + 3; \
25 array[i + 4] = i + 4; \
26
27volatile int ten = 10;
28unsigned kNumIterations = 10;
29
30int main(int argc, char **argv) {
31 char a[10];
32 char b[10];
33
34 if (argc == 1) {
35 for (int i = 0; i < kNumIterations; ++i) {
36 // CHECK: READ of size 1
37 volatile int res = a[ten + i];
38 // CHECK: WRITE of size 1
39 a[i + ten] = res + 3;
40 // CHECK: READ of size 1
41 res = a[ten + i];
42 // CHECK-NOT: ERROR
43 }
44 } else {
45 for (int i = 0; i < kNumIterations; ++i) {
46 ACCESS_ARRAY_FIVE_ELEMENTS(a, ten);
47 ACCESS_ARRAY_FIVE_ELEMENTS(a, ten + 5);
48 ACCESS_ARRAY_FIVE_ELEMENTS(a, ten + 10);
49 ACCESS_ARRAY_FIVE_ELEMENTS(b, ten);
50 ACCESS_ARRAY_FIVE_ELEMENTS(b, ten + 5);
51 ACCESS_ARRAY_FIVE_ELEMENTS(b, ten + 10);
52 }
53 }
54 return 0;
55}
56
57

source code of compiler-rt/test/asan/TestCases/Posix/halt_on_error_suppress_equal_pcs.cpp