brintos

brintos / llvm-project-archived public Read only

0
0
Text · 885 B · 9b1b88d Raw
27 lines · c
1// RUN: %clang_hwasan %s -o %t2// RUN: not %run %t 50 2>&1 | FileCheck %s3// RUN: not %run %t 40 2>&1 | FileCheck %s4// RUN: not %run %t 30 2>&1 | FileCheck %s5 6#include <stdlib.h>7#include <stdio.h>8#include <sanitizer/hwasan_interface.h>9 10int main(int argc, char **argv) {11  __hwasan_enable_allocator_tagging();12  if (argc != 2) return 0;13  int realloc_size = atoi(argv[1]);14  char * volatile x = (char*)malloc(40);15  free(x);16  x = realloc(x, realloc_size);17  // CHECK: ERROR: HWAddressSanitizer: invalid-free on address18  // CHECK: tags: [[PTR_TAG:..]]/[[MEM_TAG:..]] (ptr/mem)19  // CHECK: freed by thread {{.*}} here:20  // CHECK: previously allocated by thread {{.*}} here:21  // CHECK: Memory tags around the buggy address (one tag corresponds to 16 bytes):22  // CHECK: =>{{.*}}[[MEM_TAG]]23  fprintf(stderr, "DONE\n");24  __hwasan_disable_allocator_tagging();25// CHECK-NOT: DONE26}27