summaryrefslogtreecommitdiffstats
path: root/lib/asan/output_tests/large_func_test.cc
blob: 49751b39277af8300ad2a42d38ae721b948489bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdlib.h>
__attribute__((noinline))
static void LargeFunction(int *x, int zero) {
  x[0]++;
  x[1]++;
  x[2]++;
  x[3]++;
  x[4]++;
  x[5]++;
  x[6]++;
  x[7]++;
  x[8]++;
  x[9]++;

  x[zero + 111]++;  // we should report this exact line

  x[10]++;
  x[11]++;
  x[12]++;
  x[13]++;
  x[14]++;
  x[15]++;
  x[16]++;
  x[17]++;
  x[18]++;
  x[19]++;
}

int main(int argc, char **argv) {
  int *x = new int[100];
  LargeFunction(x, argc - 1);
  delete x;
}

// Check-Common: {{.*ERROR: AddressSanitizer heap-buffer-overflow on address}}
// Check-Common:   {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
// Check-Common: {{READ of size 4 at 0x.* thread T0}}

// atos incorrectly extracts the symbol name for the static functions on
// Darwin.
// Check-Linux:  {{    #0 0x.* in LargeFunction.*large_func_test.cc:15}}
// Check-Darwin: {{    #0 0x.* in .*LargeFunction.*large_func_test.cc:15}}

// Check-Common: {{    #1 0x.* in main .*large_func_test.cc:31}}
// Check-Common: {{0x.* is located 44 bytes to the right of 400-byte region}}
// Check-Common: {{allocated by thread T0 here:}}
// Check-Common: {{    #0 0x.* in operator new.*}}
// Check-Common: {{    #1 0x.* in main .*large_func_test.cc:30}}
OpenPOWER on IntegriCloud