From fe23fbd0f1ee9becbe5fe482a2d8fe161bdc9a94 Mon Sep 17 00:00:00 2001 From: yuencong Date: Tue, 18 Jun 2024 10:46:13 +0800 Subject: [PATCH] Filter out NSException in cxa_throw --- .../Monitors/KSCrashMonitor_CPPException.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/KSCrashRecording/Monitors/KSCrashMonitor_CPPException.cpp b/Sources/KSCrashRecording/Monitors/KSCrashMonitor_CPPException.cpp index 62d4a7dbb..31389e233 100644 --- a/Sources/KSCrashRecording/Monitors/KSCrashMonitor_CPPException.cpp +++ b/Sources/KSCrashRecording/Monitors/KSCrashMonitor_CPPException.cpp @@ -77,8 +77,12 @@ static KSStackCursor g_stackCursor; #pragma mark - Callbacks - // ============================================================================ -static void captureStackTrace(void*, std::type_info*, void (*)(void*)) __attribute__((disable_tail_calls)) +static void captureStackTrace(void*, std::type_info* tinfo, void (*)(void*)) __attribute__((disable_tail_calls)) { + if (tinfo != nullptr && strcmp(tinfo->name(), "NSException") == 0) + { + return; + } if(g_captureNextStackTrace) { kssc_initSelfThread(&g_stackCursor, 2); @@ -97,7 +101,7 @@ extern "C" static cxa_throw_type orig_cxa_throw = NULL; if (g_cxaSwapEnabled == false) { - captureStackTrace(NULL, NULL, NULL); + captureStackTrace(thrown_exception, tinfo, dest); } unlikely_if(orig_cxa_throw == NULL) {