From 3511022f5f0a8cce67b41a63c33f4f84159968e9 Mon Sep 17 00:00:00 2001 From: Matt Morehouse Date: Wed, 21 Apr 2021 17:06:09 -0700 Subject: [PATCH] [HWASan] Untag argument to __hwasan_tag_memory. __hwasan_tag_memory expects untagged pointers, so make sure our pointer is untagged. --- compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp b/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp index 1abe209c10b5f6..285a321c1f2eb0 100644 --- a/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp +++ b/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp @@ -8,7 +8,10 @@ #include int main() { - char *p = (char *)malloc(4096); + void *alloc = malloc(4096); + + // __hwasan_tag_memory expects untagged pointers. + char *p = (char *)__hwasan_tag_pointer(alloc, 0); assert(p); __hwasan_tag_memory(p, 1, 32); @@ -26,5 +29,5 @@ int main() { // CHECK-NEXT: {{.*}}0: 0 // CHECK-NEXT: {{.*}}0: 4 - free(p); + free(alloc); }