Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 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 -c 'ERROR: AddressSanitizer: stack-buffer-overflow' %t1.log) -eq 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: %env_asan_opts=halt_on_error=false:suppress_equal_pcs=false %run %t > %t2.log 2>&1 |
| 17 | // RUN: [ $(grep -c 'ERROR: AddressSanitizer: stack-buffer-overflow' %t2.log) -eq 30 ] |
| 18 | |
| 19 | #define ACCESS_ARRAY_FIVE_ELEMENTS(array, i) \ |
| 20 | array[i] = i; \ |
| 21 | array[i + 1] = i + 1; \ |
| 22 | array[i + 2] = i + 2; \ |
| 23 | array[i + 3] = i + 3; \ |
| 24 | array[i + 4] = i + 4; \ |
| 25 | |
| 26 | volatile int ten = 10; |
| 27 | unsigned kNumIterations = 10; |
| 28 | |
| 29 | int main(int argc, char **argv) { |
| 30 | char a[10]; |
| 31 | char b[10]; |
| 32 | |
| 33 | if (argc == 1) { |
| 34 | for (int i = 0; i < kNumIterations; ++i) { |
| 35 | // CHECK: READ of size 1 |
| 36 | volatile int res = a[ten + i]; |
| 37 | // CHECK: WRITE of size 1 |
| 38 | a[i + ten] = res + 3; |
| 39 | // CHECK: READ of size 1 |
| 40 | res = a[ten + i]; |
| 41 | // CHECK-NOT: ERROR |
| 42 | } |
| 43 | } else { |
| 44 | for (int i = 0; i < kNumIterations; ++i) { |
| 45 | ACCESS_ARRAY_FIVE_ELEMENTS(a, ten); |
| 46 | ACCESS_ARRAY_FIVE_ELEMENTS(a, ten + 5); |
| 47 | ACCESS_ARRAY_FIVE_ELEMENTS(a, ten + 10); |
| 48 | ACCESS_ARRAY_FIVE_ELEMENTS(b, ten); |
| 49 | ACCESS_ARRAY_FIVE_ELEMENTS(b, ten + 5); |
| 50 | ACCESS_ARRAY_FIVE_ELEMENTS(b, ten + 10); |
| 51 | } |
| 52 | } |
| 53 | return 0; |
| 54 | } |
| 55 | |