diff --git a/Classes/BITCrashCXXExceptionHandler.mm b/Classes/BITCrashCXXExceptionHandler.mm index cd427ee051..174f3b6239 100644 --- a/Classes/BITCrashCXXExceptionHandler.mm +++ b/Classes/BITCrashCXXExceptionHandler.mm @@ -66,6 +66,8 @@ extern "C" void LIBCXXABI_NORETURN __cxxabiv1::__cxa_throw(void *exception_objec // implementation of objc_exception_throw(). It's weird, but it's fast. The // weak import and NULL checks should guard against the implementation // changing in a future version. + + // This works for C++ crashes in the main app but not yet in dynamic frameworks on iOS extern const void WEAK_IMPORT_ATTRIBUTE *objc_ehtype_vtable[]; if (tinfo && objc_ehtype_vtable && // Guard from an ABI change *reinterpret_cast(tinfo) == objc_ehtype_vtable + 2) { @@ -132,17 +134,12 @@ static void BITCrashUncaughtCXXTerminateHandler(void) BITCrashCXXExceptionTSInfo *recorded_info = reinterpret_cast(pthread_getspecific(_BITCrashCXXExceptionInfoTSDKey)); if (recorded_info) { - if (__cxxabiv1::__cxa_current_primary_exception() != recorded_info->exception_object) { -#if DEBUG - fprintf(stderr, "HockeyApp: Warning - using the backtrace from a non-matching C++ exception!\n"); -#endif - } info.exception_frames_count = recorded_info->num_frames - 1; info.exception_frames = &recorded_info->call_stack[1]; } else { // There's no backtrace, grab this function's trace instead. #if DEBUG - fprintf(stderr, "HockeyApp: Warning - no backtrace available, where did this exception come from?\n"); + fprintf(stderr, "[HockeySDK] WARNING: No backtrace available, where did this exception come from?\n"); #endif void *frames[128] = { nullptr }; diff --git a/Classes/BITCrashManager.m b/Classes/BITCrashManager.m index f2b8683739..c0b338cdc3 100644 --- a/Classes/BITCrashManager.m +++ b/Classes/BITCrashManager.m @@ -103,18 +103,7 @@ static PLCrashReporterCallbacks plCrashCallbacks = { // Temporary class until PLCR catches up // We trick PLCR with an Objective-C exception. // -// This code provides us access to the C++ exception message, but we won't get a correct stack trace. -// The cause for this is that the iOS runtime catches every C++ exception internally and rethrows it. -// Since the exception object doesn't have the backtrace attached, we have no chance of accessing it. -// -// As a workaround we could hook into __cxx_throw and attaching the backtrace every time this is called. -// This has a few sides effects which is why we are not doing this right now: -// - CoreAdudio (and possibly other frameworks) use C++ exceptions heavily for control flow. -// Calling `backtrace()` is not cheap, so this could affect performance -// - It is not clear if such a hook is ABI compatible with all C++ runtimes -// - It is not clear if there could be any other side effects -// -// We'll evaluate this further to see if there is a safe solution. +// This code provides us access to the C++ exception message, including a correct stack trace. // @interface BITCrashCXXExceptionWrapperException : NSException - (instancetype)initWithCXXExceptionInfo:(const BITCrashUncaughtCXXExceptionInfo *)info; diff --git a/Support/HockeySDK.xcodeproj/project.pbxproj b/Support/HockeySDK.xcodeproj/project.pbxproj index 015d3f22c0..f56ab656a4 100644 --- a/Support/HockeySDK.xcodeproj/project.pbxproj +++ b/Support/HockeySDK.xcodeproj/project.pbxproj @@ -469,6 +469,7 @@ 1E84DB3317E0977C00AC83FD /* HockeySDKFeatureConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HockeySDKFeatureConfig.h; sourceTree = ""; }; 1E85C5601B3438E000CE2C0D /* live_report_exception_marketing.plcrash */ = {isa = PBXFileReference; lastKnownFileType = file; path = live_report_exception_marketing.plcrash; sourceTree = ""; }; 1E85C5611B3438E000CE2C0D /* live_report_signal_marketing.plcrash */ = {isa = PBXFileReference; lastKnownFileType = file; path = live_report_signal_marketing.plcrash; sourceTree = ""; }; + 1E85C5A11B35BD7000CE2C0D /* module_crashonly.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module_crashonly.modulemap; sourceTree = ""; }; 1E90D97A19DAD8A800188C43 /* feedbackActivity.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = feedbackActivity.png; sourceTree = ""; }; 1E90D97B19DAD8A800188C43 /* feedbackActivity@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "feedbackActivity@2x.png"; sourceTree = ""; }; 1E90D97C19DAD8A800188C43 /* feedbackActivity@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "feedbackActivity@2x~ipad.png"; sourceTree = ""; }; @@ -709,6 +710,7 @@ 1E754DC61621BC170070AB92 /* HockeySDK.xcconfig */, 1E66CA9115D4100500F35BED /* buildnumber.xcconfig */, 1E7DE39619D44DC6009AB8E5 /* crashonly.xcconfig */, + 1E85C5A11B35BD7000CE2C0D /* module_crashonly.modulemap */, 1E91D84619B924E600E9616D /* module.modulemap */, ); name = Support;