1 // RUN: %clangxx_hwasan %s -o %t
2 // RUN: %env_hwasan_opts=halt_on_error=0 not %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST --check-prefixes=CHECK,RECOVER
3 // RUN: %env_hwasan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST
5 #include <sanitizer/hwasan_interface.h>
11 __attribute__((no_sanitize("hwaddress"))) void
12 ForceCallInterceptor(void *p
, int c
, size_t size
) {
13 memset(p
, c
, size
) == nullptr;
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
);
21 void *volatile p2
= p
;
22 for (int i
= 0; p2
== p
; p2
= __hwasan_tag_pointer(p
, ++i
)) {
24 ForceCallInterceptor(p2
, 0, size
);
26 fprintf(stderr
, "RETURN_FROM_TEST\n");
28 // CHECK: HWAddressSanitizer: tag-mismatch on address
29 // CHECK: WRITE of size 4
30 // CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memset-recover.cpp:[[@LINE-28]]
31 // RECOVER: RETURN_FROM_TEST