diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.cpp b/compiler-rt/lib/hwasan/hwasan_allocator.cpp --- a/compiler-rt/lib/hwasan/hwasan_allocator.cpp +++ b/compiler-rt/lib/hwasan/hwasan_allocator.cpp @@ -381,9 +381,12 @@ if (tagged_ptr_old && tagged_ptr_new) { Metadata *meta = reinterpret_cast(allocator.GetMetaData(untagged_ptr_old)); - internal_memcpy( - UntagPtr(tagged_ptr_new), untagged_ptr_old, - Min(new_size, static_cast(meta->GetRequestedSize()))); + void *untagged_ptr_new = + InTaggableRegion(reinterpret_cast(tagged_ptr_new)) + ? UntagPtr(tagged_ptr_new) + : tagged_ptr_new; + internal_memcpy(untagged_ptr_new, untagged_ptr_old, + Min(new_size, static_cast(meta->GetRequestedSize()))); HwasanDeallocate(stack, tagged_ptr_old); } return tagged_ptr_new; diff --git a/compiler-rt/test/sanitizer_common/TestCases/max_allocation_size.cpp b/compiler-rt/test/sanitizer_common/TestCases/max_allocation_size.cpp --- a/compiler-rt/test/sanitizer_common/TestCases/max_allocation_size.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/max_allocation_size.cpp @@ -43,9 +43,6 @@ // win32 is disabled due to failing errno tests. // UNSUPPORTED: ubsan, target={{.*windows-msvc.*}} -// FIXME: Something crashes. -// XFAIL: hwasan-aliasing - #include #include #include