1 // RUN: %clangxx_hwasan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
2 // RUN: %clangxx_hwasan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
3 // RUN: %clangxx_hwasan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
4 // RUN: %clangxx_hwasan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
6 #include <sanitizer/hwasan_interface.h>
11 __attribute__((no_sanitize("hwaddress"))) void
12 ForceCallInterceptor(void *p
, const void *a
, size_t size
) {
16 int main(int argc
, char **argv
) {
17 __hwasan_enable_allocator_tagging();
18 char a
[] = {static_cast<char>(argc
), 2, 3, 4};
20 char *volatile p
= (char *)malloc(size
);
22 ForceCallInterceptor(p
, a
, size
);
24 // CHECK: HWAddressSanitizer: tag-mismatch on address
25 // CHECK: WRITE of size 4
26 // CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memcpy.cpp:[[@LINE-4]]
27 // CHECK: Cause: use-after-free
28 // CHECK: freed by thread
29 // CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memcpy.cpp:[[@LINE-8]]
30 // CHECK: previously allocated by thread
31 // CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memcpy.cpp:[[@LINE-11]]