diff --git a/compiler-rt/lib/asan/asan_allocator.cpp b/compiler-rt/lib/asan/asan_allocator.cpp --- a/compiler-rt/lib/asan/asan_allocator.cpp +++ b/compiler-rt/lib/asan/asan_allocator.cpp @@ -1100,6 +1100,10 @@ return m ? m->Beg() : 0; } +uptr GetUserAddr(uptr chunk) { + return chunk; +} + LsanMetadata::LsanMetadata(uptr chunk) { metadata_ = chunk ? reinterpret_cast(chunk - __asan::kChunkHeaderSize) : nullptr; 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 @@ -534,6 +534,13 @@ return reinterpret_cast(block); } +uptr GetUserAddr(uptr chunk) { + tag_t mem_tag = *(tag_t *)__hwasan::MemToShadow(chunk); + if (!__hwasan::InTaggableRegion(chunk)) + return chunk; + return AddTagToPointer(chunk, mem_tag); +} + LsanMetadata::LsanMetadata(uptr chunk) { if (__hwasan::InTaggableRegion(chunk)) CHECK_EQ(UntagAddr(chunk), chunk); diff --git a/compiler-rt/lib/lsan/lsan_allocator.cpp b/compiler-rt/lib/lsan/lsan_allocator.cpp --- a/compiler-rt/lib/lsan/lsan_allocator.cpp +++ b/compiler-rt/lib/lsan/lsan_allocator.cpp @@ -275,6 +275,10 @@ return chunk; } +uptr GetUserAddr(uptr chunk) { + return chunk; +} + LsanMetadata::LsanMetadata(uptr chunk) { metadata_ = Metadata(reinterpret_cast(chunk)); CHECK(metadata_); diff --git a/compiler-rt/lib/lsan/lsan_common.h b/compiler-rt/lib/lsan/lsan_common.h --- a/compiler-rt/lib/lsan/lsan_common.h +++ b/compiler-rt/lib/lsan/lsan_common.h @@ -131,6 +131,9 @@ uptr PointsIntoChunk(void *p); // Returns address of user-visible chunk contained in this allocator chunk. uptr GetUserBegin(uptr chunk); +// Returns user-visible address for chunk. If memory tagging is used this +// function will return the tagged address. +uptr GetUserAddr(uptr chunk); // Wrapper for chunk metadata operations. class LsanMetadata { diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp --- a/compiler-rt/lib/lsan/lsan_common.cpp +++ b/compiler-rt/lib/lsan/lsan_common.cpp @@ -859,7 +859,7 @@ leaks_.push_back(leak); } if (flags()->report_objects) { - LeakedObject obj = {leaks_[i].id, chunk, leaked_size}; + LeakedObject obj = {leaks_[i].id, GetUserAddr(chunk), leaked_size}; leaked_objects_.push_back(obj); } } diff --git a/compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp b/compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp --- a/compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp +++ b/compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp @@ -4,9 +4,6 @@ // RUN: %env_lsan_opts="report_objects=1:use_stacks=0:use_registers=0:use_tls=1" %run %t 2>&1 // RUN: %env_lsan_opts="" %run %t 2>&1 -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - #include #include #include @@ -34,4 +31,4 @@ // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]] // CHECK: LeakSanitizer: detected memory leaks // CHECK: [[ADDR]] (1337 bytes) -// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: +// CHECK: SUMMARY: {{.*}}Sanitizer: diff --git a/compiler-rt/test/lsan/TestCases/Linux/use_tls_static.cpp b/compiler-rt/test/lsan/TestCases/Linux/use_tls_static.cpp --- a/compiler-rt/test/lsan/TestCases/Linux/use_tls_static.cpp +++ b/compiler-rt/test/lsan/TestCases/Linux/use_tls_static.cpp @@ -4,9 +4,6 @@ // RUN: %env_lsan_opts="report_objects=1:use_stacks=0:use_registers=0:use_tls=1" %run %t 2>&1 // RUN: %env_lsan_opts="" %run %t 2>&1 -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - #include #include #include "sanitizer_common/print_address.h" @@ -21,4 +18,4 @@ // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]] // CHECK: LeakSanitizer: detected memory leaks // CHECK: [[ADDR]] (1337 bytes) -// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: +// CHECK: SUMMARY: {{.*}}Sanitizer: diff --git a/compiler-rt/test/lsan/TestCases/pointer_to_self.cpp b/compiler-rt/test/lsan/TestCases/pointer_to_self.cpp --- a/compiler-rt/test/lsan/TestCases/pointer_to_self.cpp +++ b/compiler-rt/test/lsan/TestCases/pointer_to_self.cpp @@ -3,9 +3,6 @@ // RUN: %clangxx_lsan %s -o %t // RUN: %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=0" not %run %t 2>&1 | FileCheck %s -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - #include #include #include "sanitizer_common/print_address.h" @@ -18,4 +15,4 @@ // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]] // CHECK: LeakSanitizer: detected memory leaks // CHECK: [[ADDR]] (1337 bytes) -// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: +// CHECK: SUMMARY: {{.*}}Sanitizer: diff --git a/compiler-rt/test/lsan/TestCases/use_after_return.cpp b/compiler-rt/test/lsan/TestCases/use_after_return.cpp --- a/compiler-rt/test/lsan/TestCases/use_after_return.cpp +++ b/compiler-rt/test/lsan/TestCases/use_after_return.cpp @@ -5,9 +5,6 @@ // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=1 %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=1" %run %t 2>&1 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=1 %env_lsan_opts="" %run %t 2>&1 -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - // Investigate why it does not fail with use_stack=0 // UNSUPPORTED: arm-linux || armhf-linux @@ -26,4 +23,4 @@ // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]] // CHECK: LeakSanitizer: detected memory leaks // CHECK: [[ADDR]] (1337 bytes) -// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: +// CHECK: SUMMARY: {{.*}}Sanitizer: diff --git a/compiler-rt/test/lsan/TestCases/use_globals_initialized.cpp b/compiler-rt/test/lsan/TestCases/use_globals_initialized.cpp --- a/compiler-rt/test/lsan/TestCases/use_globals_initialized.cpp +++ b/compiler-rt/test/lsan/TestCases/use_globals_initialized.cpp @@ -4,9 +4,6 @@ // RUN: %env_lsan_opts="report_objects=1:use_stacks=0:use_registers=0:use_globals=1" %run %t 2>&1 // RUN: %env_lsan_opts="" %run %t 2>&1 -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - #include #include #include "sanitizer_common/print_address.h" @@ -21,4 +18,4 @@ // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]] // CHECK: LeakSanitizer: detected memory leaks // CHECK: [[ADDR]] (1337 bytes) -// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: +// CHECK: SUMMARY: {{.*}}Sanitizer: diff --git a/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cpp b/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cpp --- a/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cpp +++ b/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cpp @@ -4,9 +4,6 @@ // RUN: %env_lsan_opts="report_objects=1:use_stacks=0:use_registers=0:use_globals=1" %run %t 2>&1 // RUN: %env_lsan_opts="" %run %t 2>&1 -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - #include #include #include "sanitizer_common/print_address.h" @@ -21,4 +18,4 @@ // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]] // CHECK: LeakSanitizer: detected memory leaks // CHECK: [[ADDR]] (1337 bytes) -// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: +// CHECK: SUMMARY: {{.*}}Sanitizer: diff --git a/compiler-rt/test/lsan/TestCases/use_stacks.cpp b/compiler-rt/test/lsan/TestCases/use_stacks.cpp --- a/compiler-rt/test/lsan/TestCases/use_stacks.cpp +++ b/compiler-rt/test/lsan/TestCases/use_stacks.cpp @@ -4,9 +4,6 @@ // RUN: %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=1" %run %t 2>&1 // RUN: %env_lsan_opts="" %run %t 2>&1 -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - #include #include #include "sanitizer_common/print_address.h" @@ -20,4 +17,4 @@ // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]] // CHECK: LeakSanitizer: detected memory leaks // CHECK: [[ADDR]] (1337 bytes) -// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: +// CHECK: SUMMARY: {{.*}}Sanitizer: diff --git a/compiler-rt/test/lsan/TestCases/use_unaligned.cpp b/compiler-rt/test/lsan/TestCases/use_unaligned.cpp --- a/compiler-rt/test/lsan/TestCases/use_unaligned.cpp +++ b/compiler-rt/test/lsan/TestCases/use_unaligned.cpp @@ -3,9 +3,6 @@ // RUN: %env_lsan_opts="report_objects=1:use_stacks=0:use_registers=0:use_unaligned=0" not %run %t 2>&1 | FileCheck %s // RUN: %env_lsan_opts="report_objects=1:use_stacks=0:use_registers=0:use_unaligned=1" %run %t 2>&1 -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - #include #include #include @@ -23,4 +20,4 @@ // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]] // CHECK: LeakSanitizer: detected memory leaks // CHECK: [[ADDR]] (1337 bytes) -// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: +// CHECK: SUMMARY: {{.*}}Sanitizer: