1 // Checks how we print the developer note "hwasan_dev_note_heap_rb_distance". 2 // RUN: %clang_hwasan %s -o %t 3 // RUN: not %run %t 10 2>&1 | FileCheck %s --check-prefix=D10 4 // RUN: not %run %t 42 2>&1 | FileCheck %s --check-prefix=D42 5 6 // REQUIRES: stable-runtime 7 8 #include <stdlib.h> 9 #include <stdio.h> 10 #include <sanitizer/hwasan_interface.h> 11 12 13 void *p[100]; 14 main(int argc,char ** argv)15int main(int argc, char **argv) { 16 __hwasan_enable_allocator_tagging(); 17 int distance = argc >= 2 ? atoi(argv[1]) : 1; 18 for (int i = 0; i < 100; i++) 19 p[i] = malloc(i); 20 for (int i = 0; i < 100; i++) 21 free(p[i]); 22 23 *(int*)p[distance] = 0; 24 } 25 26 // D10: hwasan_dev_note_heap_rb_distance: 90 1023 27 // D42: hwasan_dev_note_heap_rb_distance: 58 1023 28