From 05c2d6f0d7ceb98905a8b1a20954db4bae15f9e0 Mon Sep 17 00:00:00 2001 From: lightaooii Date: Sat, 11 Jan 2025 09:12:39 +0800 Subject: [PATCH] [GWPAsan]Fix pthread_atfork_for_gwpasan link error Isuue: https://gitee.com/openharmony/third_party_llvm-project/issues/IBERRJ Signed-off-by: gaohongtao --- .../platform_specific/guarded_pool_allocator_posix.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp b/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp index 451eb2739226..bbf251a90cdd 100644 --- a/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp +++ b/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp @@ -99,6 +99,10 @@ size_t GuardedPoolAllocator::getPlatformPageSize() { return sysconf(_SC_PAGESIZE); } +#if defined(__OHOS__) + extern "C" GWP_ASAN_WEAK int pthread_atfork_for_gwpasan(void (*)(void), void (*)(void), void (*)(void)); +#endif + void GuardedPoolAllocator::installAtFork() { auto Disable = []() { if (auto *S = getSingleton()) @@ -109,6 +113,8 @@ void GuardedPoolAllocator::installAtFork() { S->enable(); }; #if defined(__OHOS__) + Check(pthread_atfork_for_gwpasan, + "No implement for pthread_atfork_for_gwpasan"); // We need to run the gwpasan handler to unlock first after the fork, // otherwise other handlers may call gwpasan malloc to cause a deadlock. // This interface will let the gwpasan handler to be executed first after the fork. -- Gitee