From 63409d3f87ad45eeb18ed8c9a00eabb62dde68c4 Mon Sep 17 00:00:00 2001 From: yinchuang Date: Thu, 10 Oct 2024 09:29:14 +0800 Subject: [PATCH] [compiler-rt] Solve the potential deadlock problem of gwpasan Issue:IAVVUC Signed-off-by: yinchuang --- .../platform_specific/guarded_pool_allocator_posix.cpp | 7 +++++++ 1 file changed, 7 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 149b74238f0d..451eb2739226 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 @@ -108,6 +108,13 @@ void GuardedPoolAllocator::installAtFork() { if (auto *S = getSingleton()) S->enable(); }; +#if defined(__OHOS__) + // 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. + pthread_atfork_for_gwpasan(Disable, Enable, Enable); // OHOS_LOCAL +#else pthread_atfork(Disable, Enable, Enable); +#endif } } // namespace gwp_asan -- Gitee