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