1// RUN: %clang_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s
2
3#include <sanitizer/hwasan_interface.h>
4#include <stdlib.h>
5
6int main() {
7 __hwasan_enable_allocator_tagging();
8 char *p = (char *)malloc(size: 1);
9 realloc(ptr: p + 0x10000000000, size: 2);
10 // CHECK: ERROR: HWAddressSanitizer: invalid-free on address {{.*}} at pc {{[0x]+}}[[PC:.*]] on thread T{{[0-9]+}}
11 // CHECK: #0 {{[0x]+}}{{.*}}[[PC]] in {{.*}}realloc
12 // CHECK: #1 {{.*}} in main {{.*}}wild-free-realloc.c:[[@LINE-3]]
13 // CHECK-NOT: Segmentation fault
14 // CHECK-NOT: SIGSEGV
15 return 0;
16}
17

source code of compiler-rt/test/hwasan/TestCases/wild-free-realloc.c