From 9c312ca69f5212df94279f489aae985c4e702bf9 Mon Sep 17 00:00:00 2001 From: Elfgo Date: Thu, 19 Jun 2025 06:52:16 +0000 Subject: [PATCH] [BugFix][GWP_ASan] Fix DeadLock in GWP_ASan Change-Id: Ia12b1abffe2ea45bd1083b206266d32dccb899b8 Signed-off-by: Elfgo --- .../lib/gwp_asan/optional/segv_handler_posix.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/compiler-rt/lib/gwp_asan/optional/segv_handler_posix.cpp b/compiler-rt/lib/gwp_asan/optional/segv_handler_posix.cpp index c55175fca11f..9567e752697c 100644 --- a/compiler-rt/lib/gwp_asan/optional/segv_handler_posix.cpp +++ b/compiler-rt/lib/gwp_asan/optional/segv_handler_posix.cpp @@ -98,9 +98,6 @@ void dumpReport(uintptr_t ErrorPtr, const gwp_asan::AllocatorState *State, assert(Metadata && "dumpReport missing Metadata."); assert(Printf && "dumpReport missing Printf."); - if (!__gwp_asan_error_is_mine(State, ErrorPtr)) - return; - Printf("*** GWP-ASan detected a memory error ***\n"); ScopedEndOfReportDecorator Decorator(Printf); @@ -167,11 +164,13 @@ SegvBacktrace_t BacktraceForSignalHandler; // OHOS_LOCAL begin #if defined(__OHOS__) static bool sigSegvHandlerOhos(int sig, siginfo_t *info, void *ucontext) { - if (GPAForSignalHandler) { + uintptr_t ErrorPtr = reinterpret_cast(info->si_addr); + const gwp_asan::AllocatorState *State = + GPAForSignalHandler->getAllocatorState(); + + if (__gwp_asan_error_is_mine(State, ErrorPtr)) { GPAForSignalHandler->stop(); - dumpReport(reinterpret_cast(info->si_addr), - GPAForSignalHandler->getAllocatorState(), - GPAForSignalHandler->getMetadataRegion(), + dumpReport(ErrorPtr, State, GPAForSignalHandler->getMetadataRegion(), BacktraceForSignalHandler, PrintfForSignalHandler, PrintBacktraceForSignalHandler, ucontext); } -- Gitee