Home | History | Annotate | Download | only in output_tests
      1 #include <stdlib.h>
      2 int main() {
      3   char *x = (char*)malloc(10 * sizeof(char));
      4   free(x);
      5   return x[5];
      6 }
      7 
      8 // Check-Common: {{.*ERROR: AddressSanitizer heap-use-after-free on address}}
      9 // Check-Common:   {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
     10 // Check-Common: {{READ of size 1 at 0x.* thread T0}}
     11 // Check-Common: {{    #0 0x.* in main .*use-after-free.cc:5}}
     12 // Check-Common: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
     13 // Check-Common: {{freed by thread T0 here:}}
     14 
     15 // Check-Linux: {{    #0 0x.* in free}}
     16 // Check-Linux: {{    #1 0x.* in main .*use-after-free.cc:[45]}}
     17 
     18 // Check-Darwin: {{    #0 0x.* in .*mz_free.*}}
     19 // We override free() on Darwin, thus no malloc_zone_free
     20 // Check-Darwin: {{    #1 0x.* in free}}
     21 // Check-Darwin: {{    #2 0x.* in main .*use-after-free.cc:[45]}}
     22 
     23 // Check-Common: {{previously allocated by thread T0 here:}}
     24 
     25 // Check-Linux: {{    #0 0x.* in malloc}}
     26 // Check-Linux: {{    #1 0x.* in main .*use-after-free.cc:3}}
     27 
     28 // Check-Darwin: {{    #0 0x.* in .*mz_malloc.*}}
     29 // Check-Darwin: {{    #1 0x.* in malloc_zone_malloc.*}}
     30 // Check-Darwin: {{    #2 0x.* in malloc.*}}
     31 // Check-Darwin: {{    #3 0x.* in main .*use-after-free.cc:3}}
     32