brintos

brintos / llvm-project-archived public Read only

0
0
Text · 732 B · f96e877 Raw
22 lines · c
1// RUN: %clang_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s2 3#include <stdio.h>4#include <stdlib.h>5 6#include <sanitizer/hwasan_interface.h>7 8int main() {9  __hwasan_enable_allocator_tagging();10  char *p = (char *)malloc(1);11  fprintf(stderr, "ALLOC %p\n", __hwasan_tag_pointer(p, 0));12  // CHECK: ALLOC {{[0x]+}}[[ADDR:.*]]13  free(p - 8);14  // CHECK: ERROR: HWAddressSanitizer: invalid-free on address {{.*}} at pc {{[0x]+}}[[PC:.*]] on thread T{{[0-9]+}}15  // CHECK: #0 {{[0x]+}}{{.*}}[[PC]] in {{.*}}free16  // CHECK: #1 {{.*}} in main {{.*}}wild-free-close.c:[[@LINE-3]]17  // CHECK: is located 8 bytes before a 1-byte region [{{[0x]+}}{{.*}}[[ADDR]]18  // CHECK-NOT: Segmentation fault19  // CHECK-NOT: SIGSEGV20  return 0;21}22