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
8 #include <sanitizer/hwasan_interface.h>
13 __attribute__((no_sanitize("hwaddress"))) void
14 ForceCallInterceptor(void *p
, const void *a
, size_t size
) {
15 assert(bcmp(p
, a
, size
) == 0);
18 int main(int argc
, char **argv
) {
19 __hwasan_enable_allocator_tagging();
20 char a
[] = {static_cast<char>(argc
), 2, 3, 4};
22 char *p
= (char *)malloc(size
);
25 ForceCallInterceptor(p
, a
, size
);
27 // CHECK: HWAddressSanitizer: tag-mismatch on address
28 // CHECK: READ of size 4
29 // CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}bcmp.cpp:[[@LINE-4]]
30 // CHECK: Cause: use-after-free
31 // CHECK: freed by thread
32 // CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}bcmp.cpp:[[@LINE-8]]
33 // CHECK: previously allocated by thread
34 // CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}bcmp.cpp:[[@LINE-12]]