Skip to content

Commit

Permalink
[HWASan] Untag argument to __hwasan_tag_memory.
Browse files Browse the repository at this point in the history
__hwasan_tag_memory expects untagged pointers, so make sure our pointer
is untagged.
  • Loading branch information
morehouse committed Apr 22, 2021
1 parent 3f1e827 commit 3511022
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
#include <sanitizer/hwasan_interface.h>

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);
Expand All @@ -26,5 +29,5 @@ int main() {
// CHECK-NEXT: {{.*}}0: 0
// CHECK-NEXT: {{.*}}0: 4

free(p);
free(alloc);
}

0 comments on commit 3511022

Please sign in to comment.