diff --git a/CHANGELOG.md b/CHANGELOG.md index c78750249d..4114b31251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ [bugsnag-android#1331](https://github.com/bugsnag/bugsnag-android/pull/1331) - Address pre-existing StrictMode violations [bugsnag-android#1328](https://github.com/bugsnag/bugsnag-android/pull/1328) +- (react-native): Update bugsnag-cocoa to v6.10.3 + - Fix another rare crash in `bsg_ksmachgetThreadQueueName`. [bugsnag-cocoa#1157](https://github.com/bugsnag/bugsnag-cocoa/pull/1157) ## 7.11.0 (2021-07-26) diff --git a/packages/react-native/ios/.bugsnag-cocoa-version b/packages/react-native/ios/.bugsnag-cocoa-version index beb2939bda..eb72399809 100644 --- a/packages/react-native/ios/.bugsnag-cocoa-version +++ b/packages/react-native/ios/.bugsnag-cocoa-version @@ -1 +1 @@ -3850d4cd88f3eeabc8fff271a1b08a6a6d4e381a +cc4b9f0815e09ef4de80b4ed09194085ac2889f7 diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json index bee7ec35db..86e836b9bd 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json @@ -1,6 +1,6 @@ { "name": "Bugsnag", - "version": "6.10.2", + "version": "6.10.3", "summary": "The Bugsnag crash reporting framework for Apple platforms.", "homepage": "https://bugsnag.com", "license": "MIT", @@ -9,7 +9,7 @@ }, "source": { "git": "https://github.com/bugsnag/bugsnag-cocoa.git", - "tag": "v6.10.2" + "tag": "v6.10.3" }, "frameworks": [ "Foundation", diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj index 42f57fe0a0..0f3db2043f 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj @@ -171,9 +171,9 @@ 008967A82486D43700DC48C2 /* KSCrashIdentifierTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966E92486D43700DC48C2 /* KSCrashIdentifierTests.m */; }; 008967A92486D43700DC48C2 /* KSCrashIdentifierTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966E92486D43700DC48C2 /* KSCrashIdentifierTests.m */; }; 008967AA2486D43700DC48C2 /* KSCrashIdentifierTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966E92486D43700DC48C2 /* KSCrashIdentifierTests.m */; }; - 008967AB2486D43700DC48C2 /* KSMach_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966EA2486D43700DC48C2 /* KSMach_Tests.m */; }; - 008967AC2486D43700DC48C2 /* KSMach_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966EA2486D43700DC48C2 /* KSMach_Tests.m */; }; - 008967AD2486D43700DC48C2 /* KSMach_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966EA2486D43700DC48C2 /* KSMach_Tests.m */; }; + 008967AB2486D43700DC48C2 /* BSG_KSMachTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966EA2486D43700DC48C2 /* BSG_KSMachTests.m */; }; + 008967AC2486D43700DC48C2 /* BSG_KSMachTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966EA2486D43700DC48C2 /* BSG_KSMachTests.m */; }; + 008967AD2486D43700DC48C2 /* BSG_KSMachTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966EA2486D43700DC48C2 /* BSG_KSMachTests.m */; }; 008967B42486D9D800DC48C2 /* BugsnagBreadcrumbs.m in Sources */ = {isa = PBXBuildFile; fileRef = 008967B22486D9D700DC48C2 /* BugsnagBreadcrumbs.m */; }; 008967B52486D9D800DC48C2 /* BugsnagBreadcrumbs.m in Sources */ = {isa = PBXBuildFile; fileRef = 008967B22486D9D700DC48C2 /* BugsnagBreadcrumbs.m */; }; 008967B62486D9D800DC48C2 /* BugsnagBreadcrumbs.m in Sources */ = {isa = PBXBuildFile; fileRef = 008967B22486D9D700DC48C2 /* BugsnagBreadcrumbs.m */; }; @@ -1132,7 +1132,7 @@ 008966E72486D43700DC48C2 /* KSCrashSentry_Signal_Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KSCrashSentry_Signal_Tests.m; sourceTree = ""; }; 008966E82486D43700DC48C2 /* KSString_Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KSString_Tests.m; sourceTree = ""; }; 008966E92486D43700DC48C2 /* KSCrashIdentifierTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KSCrashIdentifierTests.m; sourceTree = ""; }; - 008966EA2486D43700DC48C2 /* KSMach_Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KSMach_Tests.m; sourceTree = ""; }; + 008966EA2486D43700DC48C2 /* BSG_KSMachTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSG_KSMachTests.m; sourceTree = ""; }; 008967AE2486D6E100DC48C2 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Makefile; sourceTree = SOURCE_ROOT; }; 008967B22486D9D700DC48C2 /* BugsnagBreadcrumbs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagBreadcrumbs.m; sourceTree = ""; }; 008967B32486D9D700DC48C2 /* BugsnagBreadcrumbs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BugsnagBreadcrumbs.h; sourceTree = ""; }; @@ -1478,6 +1478,8 @@ 008966D32486D43700DC48C2 /* KSCrash */ = { isa = PBXGroup; children = ( + 008966D82486D43700DC48C2 /* BSG_KSMachHeadersTests.m */, + 008966EA2486D43700DC48C2 /* BSG_KSMachTests.m */, 008966D62486D43700DC48C2 /* FileBasedTestCase.h */, 008966E42486D43700DC48C2 /* FileBasedTestCase.m */, 008966E92486D43700DC48C2 /* KSCrashIdentifierTests.m */, @@ -1489,8 +1491,6 @@ 008966E52486D43700DC48C2 /* KSFileUtils_Tests.m */, 008966E02486D43700DC48C2 /* KSJSONCodec_Tests.m */, 008966DA2486D43700DC48C2 /* KSLogger_Tests.m */, - 008966EA2486D43700DC48C2 /* KSMach_Tests.m */, - 008966D82486D43700DC48C2 /* BSG_KSMachHeadersTests.m */, 008966E12486D43700DC48C2 /* KSSignalInfo_Tests.m */, 008966E82486D43700DC48C2 /* KSString_Tests.m */, 008966D52486D43700DC48C2 /* KSSysCtl_Tests.m */, @@ -2704,7 +2704,7 @@ 008967542486D43700DC48C2 /* BugsnagOnCrashTest.m in Sources */, 008967152486D43700DC48C2 /* BugsnagCollectionsTests.m in Sources */, 01E8765E256684E700F4B70A /* URLSessionMock.m in Sources */, - 008967AB2486D43700DC48C2 /* KSMach_Tests.m in Sources */, + 008967AB2486D43700DC48C2 /* BSG_KSMachTests.m in Sources */, 0089672A2486D43700DC48C2 /* BugsnagStacktraceTest.m in Sources */, 01847DAC26441A5E00ADA4C7 /* BSGInternalErrorReporterTests.m in Sources */, 0163BF5925823D8D008DC28B /* NotificationBreadcrumbTests.m in Sources */, @@ -2858,7 +2858,7 @@ 008967012486D43700DC48C2 /* BugsnagEventPersistLoadTest.m in Sources */, 008967702486D43700DC48C2 /* NSError+SimpleConstructor_Tests.m in Sources */, 0089671C2486D43700DC48C2 /* BugsnagSessionTest.m in Sources */, - 008967AC2486D43700DC48C2 /* KSMach_Tests.m in Sources */, + 008967AC2486D43700DC48C2 /* BSG_KSMachTests.m in Sources */, 0163BF5A25823D8D008DC28B /* NotificationBreadcrumbTests.m in Sources */, 01BDB1FD25DEBFB300A91FAF /* BSGEventUploadKSCrashReportOperationTests.m in Sources */, 00896A452486DBF000DC48C2 /* BugsnagConfigurationTests.m in Sources */, @@ -3022,7 +3022,7 @@ 008967022486D43700DC48C2 /* BugsnagEventPersistLoadTest.m in Sources */, 008967712486D43700DC48C2 /* NSError+SimpleConstructor_Tests.m in Sources */, 0089671D2486D43700DC48C2 /* BugsnagSessionTest.m in Sources */, - 008967AD2486D43700DC48C2 /* KSMach_Tests.m in Sources */, + 008967AD2486D43700DC48C2 /* BSG_KSMachTests.m in Sources */, 00896A462486DBF000DC48C2 /* BugsnagConfigurationTests.m in Sources */, 0089674A2486D43700DC48C2 /* BugsnagUserTest.m in Sources */, 0089673B2486D43700DC48C2 /* BugsnagEventFromKSCrashReportTest.m in Sources */, diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-iOS.xcscheme b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-iOS.xcscheme index 1cbf53208e..247e0a162e 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-iOS.xcscheme +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-iOS.xcscheme @@ -28,6 +28,13 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" codeCoverageEnabled = "YES"> + + + + diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-macOS.xcscheme b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-macOS.xcscheme index d5a67b9218..07ad78b548 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-macOS.xcscheme +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-macOS.xcscheme @@ -28,6 +28,13 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" codeCoverageEnabled = "YES"> + + + + diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-tvOS.xcscheme b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-tvOS.xcscheme index b42c0dc0dd..b88443e77a 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-tvOS.xcscheme +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/xcshareddata/xcschemes/Bugsnag-tvOS.xcscheme @@ -28,6 +28,13 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" codeCoverageEnabled = "YES"> + + + + diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.m index 2a5d4c5214..c477bfc6f7 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.m @@ -54,6 +54,7 @@ - (BugsnagEvent *)loadEventAndReturnError:(NSError * __autoreleasing *)errorPtr if (!json) { NSMutableDictionary *diagnostics = [NSMutableDictionary dictionary]; diagnostics[@"data"] = [data base64EncodedStringWithOptions:0]; + diagnostics[@"file"] = self.file; ReportInternalError(@"JSON parsing error", BSGErrorDescription(error), diagnostics); if (errorPtr) { *errorPtr = error; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.c index 7a314ec567..44c4c491b4 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.c @@ -326,31 +326,41 @@ bool bsg_ksmachgetThreadQueueName(const thread_t thread, char *const buffer, return false; } - const char *queue_name = dispatch_queue_get_label(dispatch_queue); - if (queue_name == NULL) { + // If the thread is being / has recently been destroyed, we can end up with + // pointers to deallocated memory. Using vm_read_overwrite allows us to + // avoid crashing in this scenario, but we need to check that the copied + // data looks like a valid string. + const void *ptr = dispatch_queue_get_label(dispatch_queue); + + vm_size_t bytesRead = 0; + // Not using bsg_ksmachcopyMem because it does not return bytesRead + kr = vm_read_overwrite(mach_task_self(), + (vm_address_t)ptr, (vm_size_t)bufLength - 1, + (vm_address_t)buffer, &bytesRead); + if (kr != KERN_SUCCESS) { BSG_KSLOG_TRACE("Error while getting dispatch queue name : %p", dispatch_queue); + buffer[0] = '\0'; return false; } - BSG_KSLOG_TRACE("Dispatch queue name: %s", queue_name); - size_t length = strlen(queue_name); + + buffer[bytesRead] = '\0'; + + BSG_KSLOG_TRACE("Dispatch queue name: %s", buffer); // Queue label must be a null terminated string. size_t iLabel; - for (iLabel = 0; iLabel < length + 1; iLabel++) { - if (queue_name[iLabel] < ' ' || queue_name[iLabel] > '~') { + for (iLabel = 0; iLabel < bytesRead; iLabel++) { + if (buffer[iLabel] < ' ' || buffer[iLabel] > '~') { break; } } - if (queue_name[iLabel] != 0) { + if (buffer[iLabel] != 0) { // Found a non-null, invalid char. BSG_KSLOG_TRACE("Queue label contains invalid chars"); + buffer[0] = '\0'; return false; } - bufLength = - MIN(length, bufLength - 1); // just strlen, without null-terminator - strncpy(buffer, queue_name, bufLength); - buffer[bufLength] = 0; // terminate string BSG_KSLOG_TRACE("Queue label = %s", buffer); return true; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m index 79cece5fa7..baa2bb79c6 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m @@ -23,7 +23,7 @@ - (instancetype)init { #else self.name = @"Bugsnag Objective-C"; #endif - self.version = @"6.10.2"; + self.version = @"6.10.3"; self.url = @"https://github.com/bugsnag/bugsnag-cocoa"; self.dependencies = [NSMutableArray new]; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BSGFileLocations.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BSGFileLocations.m index 14eadf9bfd..bb87ca6c3e 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BSGFileLocations.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BSGFileLocations.m @@ -7,13 +7,26 @@ // #import "BSGFileLocations.h" + +#import "BSGInternalErrorReporter.h" #import "BugsnagLogger.h" +static void ReportInternalError(NSString *errorClass, NSError *error) { + NSString *file = @(__FILE__).lastPathComponent; + NSString *message = BSGErrorDescription(error); + NSString *groupingHash = [NSString stringWithFormat:@"%@: %@: %@ %ld", file, errorClass, error.domain, (long)error.code]; + [BSGInternalErrorReporter.sharedInstance reportErrorWithClass:errorClass message:message diagnostics:error.userInfo groupingHash:groupingHash]; +} + static BOOL ensureDirExists(NSString *path) { NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *error = nil; if(![fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error]) { bsg_log_err(@"Could not create directory %@: %@", path, error); + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + ReportInternalError(@"Could not create directory", error); + }); return NO; } return YES; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md b/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md index d42f340bc3..a6462f6f1b 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========= +## 6.10.3 (2021-08-04) + +### Bug fixes + +* Fix another rare crash in `bsg_ksmachgetThreadQueueName`. + [#1157](https://github.com/bugsnag/bugsnag-cocoa/pull/1157) + ## 6.10.2 (2021-07-14) ### Bug fixes diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist b/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist index 887f9ebff4..09d91d0c23 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 6.10.2 + 6.10.3 CFBundleVersion 1 diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION b/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION index 22cb9e5536..3c02432371 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION @@ -1 +1 @@ -6.10.2 +6.10.3