diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.h b/compiler-rt/lib/hwasan/hwasan_allocator.h --- a/compiler-rt/lib/hwasan/hwasan_allocator.h +++ b/compiler-rt/lib/hwasan/hwasan_allocator.h @@ -88,6 +88,7 @@ typedef CombinedAllocator Allocator; typedef Allocator::AllocatorCache AllocatorCache; +void AllocatorThreadStart(AllocatorCache *cache); void AllocatorThreadFinish(AllocatorCache *cache); class HwasanChunkView { 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 @@ -149,8 +149,9 @@ atomic_store_relaxed(&hwasan_allocator_tagging_enabled, !flags()->disable_allocator_tagging); SetAllocatorMayReturnNull(common_flags()->allocator_may_return_null); - allocator.Init(common_flags()->allocator_release_to_os_interval_ms, - GetAliasRegionStart()); + allocator.InitLinkerInitialized( + common_flags()->allocator_release_to_os_interval_ms, + GetAliasRegionStart()); for (uptr i = 0; i < sizeof(tail_magic); i++) tail_magic[i] = GetCurrentThread()->GenerateRandomTag(); if (common_flags()->max_allocation_size_mb) { @@ -165,8 +166,11 @@ void HwasanAllocatorUnlock() { allocator.ForceUnlock(); } +void AllocatorThreadStart(AllocatorCache *cache) { allocator.InitCache(cache); } + void AllocatorThreadFinish(AllocatorCache *cache) { allocator.SwallowCache(cache); + allocator.DestroyCache(cache); } static uptr TaggedSize(uptr size) { 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 @@ -58,6 +58,7 @@ #endif InitStackAndTls(state); dtls_ = DTLS_Get(); + AllocatorThreadStart(allocator_cache()); } void Thread::InitStackRingBuffer(uptr stack_buffer_start, diff --git a/compiler-rt/test/sanitizer_common/TestCases/allocator_interface.cpp b/compiler-rt/test/sanitizer_common/TestCases/allocator_interface.cpp --- a/compiler-rt/test/sanitizer_common/TestCases/allocator_interface.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/allocator_interface.cpp @@ -4,9 +4,6 @@ // No allocator. // UNSUPPORTED: ubsan -// FIXME: implementation is incomplete. -// XFAIL: hwasan - #include #include #include