1 // RUN: %clangxx_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s
3 #include <sanitizer/hwasan_interface.h>
10 int main(int argc
, char **argv
) {
11 const size_t kPS
= sysconf(_SC_PAGESIZE
);
14 int res
= posix_memalign(&r
, kPS
, 2 * kPS
);
16 perror("Failed to mmap: ");
20 r
= __hwasan_tag_pointer(r
, 0);
21 __hwasan_tag_memory(r
, 1, 2 * kPS
);
23 // Disable access to the page just after tag-mismatch report address.
24 res
= mprotect((char*)r
+ kPS
, kPS
, PROT_NONE
);
26 perror("Failed to mprotect: ");
30 // Trigger tag-mismatch report.
31 return *((char*)r
+ kPS
- 1);
34 // CHECK: ERROR: HWAddressSanitizer: tag-mismatch on address
35 // CHECK: Memory tags around the buggy address
36 // CHECK: Tags for short granules around
38 // Check that report is complete.
39 // CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main