Home | History | Annotate | Download | only in output_tests
      1 #include <stdlib.h>
      2 __attribute__((noinline))
      3 static void LargeFunction(int *x, int zero) {
      4   x[0]++;
      5   x[1]++;
      6   x[2]++;
      7   x[3]++;
      8   x[4]++;
      9   x[5]++;
     10   x[6]++;
     11   x[7]++;
     12   x[8]++;
     13   x[9]++;
     14 
     15   x[zero + 111]++;  // we should report this exact line
     16 
     17   x[10]++;
     18   x[11]++;
     19   x[12]++;
     20   x[13]++;
     21   x[14]++;
     22   x[15]++;
     23   x[16]++;
     24   x[17]++;
     25   x[18]++;
     26   x[19]++;
     27 }
     28 
     29 int main(int argc, char **argv) {
     30   int *x = new int[100];
     31   LargeFunction(x, argc - 1);
     32   delete x;
     33 }
     34 
     35 // Check-Common: {{.*ERROR: AddressSanitizer heap-buffer-overflow on address}}
     36 // Check-Common:   {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
     37 // Check-Common: {{READ of size 4 at 0x.* thread T0}}
     38 // Check-Common: {{    #0 0x.* in LargeFunction.*large_func_test.cc:15}}
     39 // Check-Common: {{    #1 0x.* in main .*large_func_test.cc:3[012]}}
     40 // Check-Common: {{0x.* is located 44 bytes to the right of 400-byte region}}
     41 // Check-Common: {{allocated by thread T0 here:}}
     42 // Check-Common: {{    #0 0x.* in operator new.*}}
     43 // Check-Common: {{    #1 0x.* in main .*large_func_test.cc:30}}
     44