diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp --- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp +++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp @@ -39,6 +39,7 @@ INTERCEPTOR(int, pthread_create, void *th, void *attr, void *(*callback)(void*), void * param) { + EnsureMainThreadIDIsCorrect(); ScopedTaggingDisabler disabler; ThreadStartArg *A = reinterpret_cast (MmapOrDie( GetPageSizeCached(), "pthread_create")); diff --git a/compiler-rt/lib/hwasan/hwasan_thread.h b/compiler-rt/lib/hwasan/hwasan_thread.h --- a/compiler-rt/lib/hwasan/hwasan_thread.h +++ b/compiler-rt/lib/hwasan/hwasan_thread.h @@ -110,6 +110,9 @@ Thread *GetCurrentThread(); uptr *GetCurrentThreadLongPtr(); +// Used to handle fork(). +void EnsureMainThreadIDIsCorrect(); + struct ScopedTaggingDisabler { ScopedTaggingDisabler() { GetCurrentThread()->DisableTagging(); } ~ScopedTaggingDisabler() { GetCurrentThread()->EnableTagging(); } diff --git a/compiler-rt/lib/hwasan/hwasan_thread.cpp b/compiler-rt/lib/hwasan/hwasan_thread.cpp --- a/compiler-rt/lib/hwasan/hwasan_thread.cpp +++ b/compiler-rt/lib/hwasan/hwasan_thread.cpp @@ -44,6 +44,8 @@ static atomic_uint64_t unique_id; unique_id_ = atomic_fetch_add(&unique_id, 1, memory_order_relaxed); + if (!IsMainThread()) + os_id_ = GetTid(); if (auto sz = flags()->heap_history_size) heap_allocations_ = HeapAllocationsRingBuffer::New(sz); @@ -149,6 +151,12 @@ return tag; } +void EnsureMainThreadIDIsCorrect() { + auto *t = __hwasan::GetCurrentThread(); + if (t && (t->IsMainThread())) + t->set_os_id(GetTid()); +} + } // namespace __hwasan // --- Implementation of LSan-specific functions --- {{{1 @@ -169,11 +177,7 @@ void UnlockThreadRegistry() { __hwasan::hwasanThreadList().Unlock(); } -void EnsureMainThreadIDIsCorrect() { - auto *t = __hwasan::GetCurrentThread(); - if (t && (t->IsMainThread())) - t->set_os_id(GetTid()); -} +void EnsureMainThreadIDIsCorrect() { __hwasan::EnsureMainThreadIDIsCorrect(); } bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end, uptr *tls_begin, uptr *tls_end, uptr *cache_begin, diff --git a/compiler-rt/test/lsan/TestCases/Linux/cleanup_in_tsd_destructor.c b/compiler-rt/test/lsan/TestCases/Linux/cleanup_in_tsd_destructor.c --- a/compiler-rt/test/lsan/TestCases/Linux/cleanup_in_tsd_destructor.c +++ b/compiler-rt/test/lsan/TestCases/Linux/cleanup_in_tsd_destructor.c @@ -7,9 +7,6 @@ // RUN: %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=0:use_tls=1" %run %t // RUN: %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=0:use_tls=0" not %run %t 2>&1 | FileCheck %s -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - // Investigate why it does not fail with use_stack=0 // UNSUPPORTED: arm-linux || armhf-linux diff --git a/compiler-rt/test/lsan/TestCases/Linux/fork_threaded.cpp b/compiler-rt/test/lsan/TestCases/Linux/fork_threaded.cpp --- a/compiler-rt/test/lsan/TestCases/Linux/fork_threaded.cpp +++ b/compiler-rt/test/lsan/TestCases/Linux/fork_threaded.cpp @@ -3,9 +3,6 @@ // RUN: %clangxx_lsan %s -o %t // RUN: %run %t 2>&1 -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - #include #include #include diff --git a/compiler-rt/test/lsan/TestCases/Linux/guard-page.c b/compiler-rt/test/lsan/TestCases/Linux/guard-page.c --- a/compiler-rt/test/lsan/TestCases/Linux/guard-page.c +++ b/compiler-rt/test/lsan/TestCases/Linux/guard-page.c @@ -1,9 +1,6 @@ // Check that if LSan finds that SP doesn't point into thread stack (e.g. // if swapcontext is used), LSan will not hit the guard page. // RUN: %clang_lsan %s -o %t && %run %t - -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan // Missing 'getcontext' and 'makecontext' on Android. // UNSUPPORTED: android diff --git a/compiler-rt/test/lsan/TestCases/Linux/libdl_deadlock.cpp b/compiler-rt/test/lsan/TestCases/Linux/libdl_deadlock.cpp --- a/compiler-rt/test/lsan/TestCases/Linux/libdl_deadlock.cpp +++ b/compiler-rt/test/lsan/TestCases/Linux/libdl_deadlock.cpp @@ -2,9 +2,6 @@ // where lsan would call dl_iterate_phdr while holding the allocator lock. // RUN: %clangxx_lsan %s -o %t && %run %t -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - #include #include #include diff --git a/compiler-rt/test/lsan/TestCases/many_tls_keys_pthread.cpp b/compiler-rt/test/lsan/TestCases/many_tls_keys_pthread.cpp --- a/compiler-rt/test/lsan/TestCases/many_tls_keys_pthread.cpp +++ b/compiler-rt/test/lsan/TestCases/many_tls_keys_pthread.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 - // On glibc, this requires the range returned by GetTLS to include // specific_1stblock and specific in `struct pthread`. // UNSUPPORTED: arm-linux, armhf-linux @@ -77,4 +74,4 @@ } // CHECK: LeakSanitizer: detected memory leaks -// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: +// CHECK: SUMMARY: {{.*}}Sanitizer: diff --git a/compiler-rt/test/lsan/TestCases/many_tls_keys_thread.cpp b/compiler-rt/test/lsan/TestCases/many_tls_keys_thread.cpp --- a/compiler-rt/test/lsan/TestCases/many_tls_keys_thread.cpp +++ b/compiler-rt/test/lsan/TestCases/many_tls_keys_thread.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 - // Patch r303906 did not fix all the problems. // UNSUPPORTED: arm-linux,armhf-linux @@ -60,4 +57,4 @@ } // CHECK: LeakSanitizer: detected memory leaks -// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: +// CHECK: SUMMARY: {{.*}}Sanitizer: diff --git a/compiler-rt/test/lsan/TestCases/use_registers.cpp b/compiler-rt/test/lsan/TestCases/use_registers.cpp --- a/compiler-rt/test/lsan/TestCases/use_registers.cpp +++ b/compiler-rt/test/lsan/TestCases/use_registers.cpp @@ -4,9 +4,6 @@ // RUN: %env_lsan_opts="report_objects=1:use_stacks=0:use_registers=1" %run %t 2>&1 // RUN: %env_lsan_opts="" %run %t 2>&1 -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - #include "sanitizer_common/print_address.h" #include #include @@ -80,4 +77,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_registers_extra.cpp b/compiler-rt/test/lsan/TestCases/use_registers_extra.cpp --- a/compiler-rt/test/lsan/TestCases/use_registers_extra.cpp +++ b/compiler-rt/test/lsan/TestCases/use_registers_extra.cpp @@ -4,9 +4,6 @@ // RUN: %env_lsan_opts="report_objects=1:use_stacks=0:use_registers=1" %run %t 2>&1 // RUN: %env_lsan_opts="" %run %t 2>&1 -// Fixme: remove once test passes with hwasan -// UNSUPPORTED: hwasan - // FIXME: Support more platforms. // REQUIRES: x86-target-arch && linux @@ -60,4 +57,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_threaded.cpp b/compiler-rt/test/lsan/TestCases/use_stacks_threaded.cpp --- a/compiler-rt/test/lsan/TestCases/use_stacks_threaded.cpp +++ b/compiler-rt/test/lsan/TestCases/use_stacks_threaded.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 @@ -37,4 +34,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: