rollbar / rollbar-apple

Objective-C & Swift library for remote crash, exception, error reporting, and logging with Rollbar. It works on all Apple *OS platforms (macOS, iOS, tvOS, watchOS, etc).
https://docs.rollbar.com/docs/apple
MIT License
26 stars 17 forks source link

Fatal Exception [NSJSONSerialization dataWithJSONObject:options:error:]: value parameter is nil #343

Open freemansion opened 6 months ago

freemansion commented 6 months ago

Hi there. We're currently experiencing crash due improperly handled nil value inside Rollbar SDK. Here is more context:

Crash description App crashes during cold start with following end of stacktrace:

RollbarHandler.initRollbarWithUser(phone:userName:)
NSInvalidArgumentException - -[__NSCFString objectForKey:]: unrecognized selector sent to instance <address>

Rollbar-Apple SDK version: v.3.2.1 revision: 8f22deced5e5c58cfcf923395a9ac8496b3bc371

46 crashes / 18 users Operating systems 65% iOS 16 35% iOS 17

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x9e88 __exceptionPreprocess
1  libobjc.A.dylib                0x178d8 objc_exception_throw
2  Foundation                     0x51140 +[NSData(NSData) dataWithBytesNoCopy:length:freeWhenDone:]
3  RollbarCommon                  0x43c0 +[NSJSONSerialization(Rollbar) rollbar_dataWithJSONObject:options:error:safe:] + 43 (NSJSONSerialization+Rollbar.m:43)
4  RollbarNotifier                0x14b00 -[RollbarSession saveSessionState:] + 488 (RollbarSession.m:488)
5  RollbarNotifier                0x13c9c -[RollbarSession enableOomMonitoring:withCrashCheck:] + 127 (RollbarSession.m:127)
6  RollbarNotifier                0xa924 -[RollbarInfrastructure configureWith:andCrashCollector:] + 76 (RollbarInfrastructure.m:76)
7  RollbarNotifier                0x4110 +[Rollbar initWithAccessToken:configuration:crashCollector:] + 79 (Rollbar.m:79)
8  App Name                       0x286458 RollbarHandler.initRollbarWithUser(phone:userName:) + 49 (RollbarHandler.swift:49)
9  App Name                       0x421df8 AppDelegate.application(_:didFinishLaunchingWithOptions:) + 80 (AppDelegate.swift:80)
10 App Name                       0x4282b0 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) (<compiler-generated>)
11 UIKitCore                      0x35a888 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]
12 UIKitCore                      0x359fac -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]
13 UIKitCore                      0x358f88 -[UIApplication _runWithMainScene:transitionContext:completion:]
14 UIKitCore                      0x358bd4 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]
15 UIKitCore                      0x9e600 _UIScenePerformActionsWithLifecycleActionMask
16 UIKitCore                      0x3e0918 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke
17 UIKitCore                      0x291014 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
18 UIKitCore                      0x290dcc -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
19 UIKitCore                      0x29097c -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
20 UIKitCore                      0x290848 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
21 UIKitCore                      0x972fa8 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:]
22 UIKitCore                      0xa0bf98 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion
23 UIKitCore                      0x13c958 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
24 UIKitCore                      0x5af7a8 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.214
25 UIKitCore                      0x20f0b8 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]
26 UIKitCore                      0x20ef28 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:]
27 UIKitCore                      0x20e47c -[UIApplication workspace:didCreateScene:withTransitionContext:completion:]
28 UIKitCore                      0x20e208 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:]
29 FrontBoardServices             0x3500 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:]
30 FrontBoardServices             0x4251c __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke.78
31 FrontBoardServices             0x7294 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
32 FrontBoardServices             0x42154 __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke
33 libdispatch.dylib              0x3fdc _dispatch_client_callout
34 libdispatch.dylib              0x7a5c _dispatch_block_invoke_direct
35 FrontBoardServices             0x113b0 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
36 FrontBoardServices             0x10f4c -[FBSSerialQueue _targetQueue_performNextIfPossible]
37 FrontBoardServices             0x1372c -[FBSSerialQueue _performNextFromRunLoopSource]
38 CoreFoundation                 0xd5f54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
39 CoreFoundation                 0xe232c __CFRunLoopDoSource0
40 CoreFoundation                 0x66270 __CFRunLoopDoSources0
41 CoreFoundation                 0x7bba8 __CFRunLoopRun
42 CoreFoundation                 0x80ed4 CFRunLoopRunSpecific
43 GraphicsServices               0x1368 GSEventRunModal
44 UIKitCore                      0x3a23d0 -[UIApplication _run]
45 UIKitCore                      0x3a2034 UIApplicationMain
46 App Name                       0x429e38 main + 26 (AppDelegate.swift:26)
47 ???                            0x1da9c8960 (Missing)
freemansion commented 5 months ago

UPD: we have spike of 230 similar crashes, below you can see the stack trace:

Crashed: com.apple.main-thread 0 app-name 0xbe7ba0 closure #1 in RollbarCrashFormattingFilter.backtrace(for:process:) + 153556 (:153556) 1 app-name 0xbe6078 closure #1 in RollbarCrashFormattingFilter.threadInfo(for:process:) + 57 (FormatBuilder.swift:57) 2 app-name 0xbe12c4 closure #1 in RollbarCrashFormattingFilter.format(:) + 57 (FormatBuilder.swift:57) 3 app-name 0xbe0d84 RollbarCrashFormattingFilter.filterReports(:onCompletion:) + 57 (FormatBuilder.swift:57) 4 app-name 0xbe0fb0 @objc RollbarCrashFormattingFilter.filterReports(_:onCompletion:) + 125924 (:125924) 5 app-name 0xbcfdec 63-[RollbarCrashReportFilterPipeline filterReports:onCompletion:]_block_invoke_3 + 336 (RollbarCrashReportFilterBasic.m:336) 6 app-name 0xbe0b6c thunk for @escaping @calleeunowned @convention(block) (@unowned NSArray?, @unowned ObjCBool, @unowned NSError?) -> () + 124832 (:124832) 7 app-name 0xbdb124 RollbarCrashDiagnosticFilter.filterReports(:onCompletion:) + 29 (RollbarCrashDiagnosticFilter.swift:29) 8 app-name 0xbdb534 @objc RollbarCrashDiagnosticFilter.filterReports(_:onCompletion:) + 102760 (:102760) 9 app-name 0xbcfbe4 -[RollbarCrashReportFilterPipeline filterReports:onCompletion:] + 349 (RollbarCrashReportFilterBasic.m:349) 10 app-name 0xbcfdec 63-[RollbarCrashReportFilterPipeline filterReports:onCompletion:]_block_invoke3 + 336 (RollbarCrashReportFilterBasic.m:336) 11 app-name 0xbcfc60 -[RollbarCrashReportFilterPipeline filterReports:onCompletion:] + 349 (RollbarCrashReportFilterBasic.m:349) 12 app-name 0xbcfbe4 -[RollbarCrashReportFilterPipeline filterReports:onCompletion:] + 349 (RollbarCrashReportFilterBasic.m:349) 13 app-name 0xbc9214 -[RollbarCrashHandler sendReports:onCompletion:] + 443 (RollbarCrashHandler.m:443) 14 app-name 0xbc8d30 -[RollbarCrashHandler sendAllReportsWithCompletion:] + 349 (RollbarCrashHandler.m:349) 15 app-name 0xbce5ac -[RollbarCrashInstallation sendAllReportsWithCompletion:] + 355 (RollbarCrashInstallation.m:355) 16 app-name 0xc05050 -[RollbarInfrastructure configureWith:] + 51 (RollbarInfrastructure.m:51) 17 app-name 0xc02b68 +[Rollbar initWithConfiguration:] + 36 (Rollbar.m:36) 18 app-name 0x2e6f78 RollbarHandler.initRollbarWithUser(phone:userName:) + 49 (RollbarHandler.swift:49) 19 app-name 0x4d0ae0 AppDelegate.application(:didFinishLaunchingWithOptions:) + 87 (AppDelegate.swift:87) 20 app-name 0x4d7c70 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) + 4312497264 (:4312497264) 21 UIKitCore 0x35af40 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 300 22 UIKitCore 0x35a664 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 2848 23 UIKitCore 0x359640 -[UIApplication _runWithMainScene:transitionContext:completion:] + 856 24 UIKitCore 0x35928c -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 132 25 UIKitCore 0x9ed64 _UIScenePerformActionsWithLifecycleActionMask + 108 26 UIKitCore 0x3e0c3c 101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 216 27 UIKitCore 0x291888 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 220 28 UIKitCore 0x2916b0 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 620 29 UIKitCore 0x291260 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 252 30 UIKitCore 0x29112c __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 148 31 UIKitCore 0x96f5a0 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] + 736 32 UIKitCore 0xa0796c _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 224 33 UIKitCore 0x13d2d8 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 316 34 UIKitCore 0x5af048 64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.215 + 556 35 UIKitCore 0x20fbec -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 216 36 UIKitCore 0x20fa5c -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 244 37 UIKitCore 0x20efb0 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 520 38 UIKitCore 0x20ed3c -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 288 39 FrontBoardServices 0x2d48 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 344 40 FrontBoardServices 0x42104 92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke.78 + 120 41 FrontBoardServices 0x6ae4 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 168 42 FrontBoardServices 0x41d3c 92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke + 360 43 libdispatch.dylib 0x3fdc _dispatch_client_callout + 20 44 libdispatch.dylib 0x7a5c _dispatch_block_invoke_direct + 264 45 FrontBoardServices 0x10f2c FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 52 46 FrontBoardServices 0x10ac8 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 220 47 FrontBoardServices 0x132a8 -[FBSSerialQueue _performNextFromRunLoopSource] + 28 48 CoreFoundation 0xd622c CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28 49 CoreFoundation 0xe2614 CFRunLoopDoSource0 + 176 50 CoreFoundation 0x6657c CFRunLoopDoSources0 + 340 51 CoreFoundation 0x7beb8 __CFRunLoopRun + 836 52 CoreFoundation 0x811e4 CFRunLoopRunSpecific + 612 53 GraphicsServices 0x1368 GSEventRunModal + 164 54 UIKitCore 0x3a2d88 -[UIApplication _run] + 888 55 UIKitCore 0x3a29ec UIApplicationMain + 340 56 app-name 0x4da148 main + 29 (AppDelegate.swift:29) 57 ??? 0x1b6f71948 (Missing)

any plans to resolve this issue?