Using mono 2.10.9 and monomac, I have written a c# class inheriting NSObject used for Cocoa-binding from Xcode. If my class includes a property using a nullable value like this:
[Export]
public bool? IsRegistered { get; set; }
my application crashes the ugly way during startup (see crash report below). The main window hasn't even been displayed yet. As soon as I change the bool? to bool, everything works fine, but I actually would like to use bool?. Any suggestions?
Crash report:
Process: SQAT [44677]
Path: /Users/USER/*/SQAT.app/Contents/MacOS/SQAT
Identifier: SQAT
Version: 4 (1)
Code Type: X86 (Native)
Parent Process: launchd [136]
Date/Time: 2013-01-23 15:31:51.540 +0100
OS Version: Mac OS X 10.7.5 (11G63)
Report Version: 9
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
objc[44677]: garbage collection is OFF
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x95da69c6 __pthread_kill + 10
1 libsystem_c.dylib 0x90dc0f78 pthread_kill + 106
2 libsystem_c.dylib 0x90db1bdd abort + 167
3 libmono-2.0.dylib 0x0029eefd mono_handle_native_sigsegv + 685
4 libsystem_c.dylib 0x90e1659b _sigtramp + 43
5 ??? 0xffffffff 0 + 4294967295
6 libmono-2.0.dylib 0x002ed970 mono_runtime_posix_install_handlers + 288
7 libsystem_c.dylib 0x90db1bdd abort + 167
8 libmono-2.0.dylib 0x003ff47f monoeg_g_logv + 159
9 libmono-2.0.dylib 0x003ff4ab monoeg_assertion_message + 43
10 libmono-2.0.dylib 0x0035a4ee mono_marshal_emit_managed_wrapper + 782
11 libmono-2.0.dylib 0x0035ae50 mono_marshal_get_managed_wrapper + 752
12 libmono-2.0.dylib 0x0035b2a2 mono_delegate_to_ftnptr + 146
13 ??? 0x011bf4be 0 + 18609342
14 ??? 0x011bf45c 0 + 18609244
15 ??? 0x01203350 0 + 18887504
16 ??? 0x01203148 0 + 18886984
17 ??? 0x013340fc 0 + 20136188
18 ??? 0x011c10a8 0 + 18616488
19 ??? 0x011c090c 0 + 18614540
20 ??? 0x01205cd8 0 + 18898136
21 ??? 0x0092bfe0 0 + 9617376
22 ??? 0x0092b6dc 0 + 9615068
23 ??? 0x0092bdde 0 + 9616862
24 libmono-2.0.dylib 0x0020dca4 mono_jit_runtime_invoke + 164
25 libmono-2.0.dylib 0x003832e4 mono_runtime_invoke + 68
26 libmono-2.0.dylib 0x003893ae mono_runtime_exec_main + 238
27 libmono-2.0.dylib 0x002735fd mono_main + 6797
28 SQAT 0x000394bf main + 3135
29 SQAT 0x00038875 start + 53
There is no direct equivalent to bool? in ObjectiveC, so currently it is not possible to export such a property.
Exactly how are you trying to use this property from ObjectiveC?
Related
I'm getting a unconditionallyBridgeFromObjectiveC crash in an Apple Watch app out in the wild. I'm not able to replicate it locally, and haven't ever encountered it on a test device through regular use. Here's the info about the exception:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000000224c58b0
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [653]
The crash reports show it's happening on the second line of this code:
let name: String
name = WKInterfaceDevice.current().name
(I have these on separate lines for better readability in my code)
I'm not very family with Objective-C or how things can fail related to Objective-C values, but from what I've found around the Internet, here's my guess:
Even though the API says that WKInterfaceDevice.current().name is a String instead of String?, name is somehow actually a nil value in some cases.
As a possible solution, I'm thinking that instead of name: String I should use name: String? and then make sure it's non-nil later. Does this make sense? Would that help with the issue, or would it be possible that it still crashes from trying to store WKInterfaceDevice.current().name in a constant of type String?? Is there some other kind of safety check I should be doing on WKInterfaceDevice.current().name first?
This crash is not happening much (on at least 7 devices out of ~5000 in about 5 days) but it's the most frequent crash in the newest version of my app, so I'm trying to use it as a learning opportunity to make my app more robust. I guess maybe it could be an issue in WatchKit rather than a problem with my code? Or something that could only be checked and solved with Objective-C?
Stack Trace:
Hardware Model: Watch5,2
Version: 1 (2020.29)
AppVariant: 1:Watch5,2:6
Code Type: ARM (Native)
Role: Foreground
Parent Process: launchd [1]
Date/Time: 2020-05-28 14:32:42.6998 +0900
Launch Time: 2020-05-28 14:32:07.0000 +0900
OS Version: Watch OS 6.2.5 (17T608)
Release Type: User
Baseband Version: n/a
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000000224c58b0
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [653]
Triggered by Thread: 5
Thread 0 name:
Thread 0:
0 libsystem_kernel.dylib 0x21fdb134 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x21fda604 mach_msg + 72 (mach_msg.c:103)
2 libdispatch.dylib 0x21e5a49c _dispatch_mach_send_and_wait_for_reply + 580 (mach.c:830)
3 libdispatch.dylib 0x21e5a858 dispatch_mach_send_with_result_and_wait_for_reply + 52 (mach.c:2006)
4 libxpc.dylib 0x220bd150 xpc_connection_send_message_with_reply_sync + 228 (connection.c:829)
5 CoreFoundation 0x2239cfec __99-[CFPrefsPlistSource sendFullyPreparedMessage:toConnection:settingValues:forKeys:count:retryCount:]_block_invoke + 56 (CFPrefsPlistSource.m:933)
6 CoreFoundation 0x22353cb4 -[_CFXPreferences withConnectionForRole:performBlock:] + 48 (CFXPreferences.m:1330)
7 CoreFoundation 0x2239cf88 -[CFPrefsPlistSource sendFullyPreparedMessage:toConnection:settingValues:forKeys:count:retryCount:] + 188 (CFPrefsPlistSource.m:962)
8 CoreFoundation 0x2239d2c4 -[CFPrefsPlistSource sendMessageSettingValues:forKeys:count:] + 304 (CFPrefsPlistSource.m:994)
9 CoreFoundation 0x2239c0f4 -[CFPrefsPlistSource alreadylocked_setPrecopiedValues:forKeys:count:from:] + 948 (CFPrefsPlistSource.m:397)
10 CoreFoundation 0x2249ac9c -[CFPrefsSource setValues:forKeys:count:copyValues:removeValuesForKeys:count:from:] + 392 (CFPrefsSource.m:771)
11 CoreFoundation 0x2249affc -[CFPrefsSource setValues:forKeys:count:copyValues:from:] + 36 (CFPrefsSource.m:793)
12 CoreFoundation 0x223d74e4 -[CFPrefsSearchListSource alreadylocked_setPrecopiedValues:forKeys:count:from:] + 968 (CFPrefsSearchListSource.m:738)
13 CoreFoundation 0x2249ac9c -[CFPrefsSource setValues:forKeys:count:copyValues:removeValuesForKeys:count:from:] + 392 (CFPrefsSource.m:771)
14 CoreFoundation 0x2249affc -[CFPrefsSource setValues:forKeys:count:copyValues:from:] + 36 (CFPrefsSource.m:793)
15 CoreFoundation 0x2234fc04 -[CFPrefsSource setValue:forKey:from:] + 64 (CFPrefsSource.m:799)
16 CoreFoundation 0x224a3008 __76-[_CFXPreferences setValue:forKey:appIdentifier:container:configurationURL:]_block_invoke + 64 (CFXPreferences.m:795)
17 CoreFoundation 0x223d9540 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 372 (CFPrefsSearchListSource.m:1719)
18 CoreFoundation 0x2234c6bc -[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 340 (CFPrefsSearchListSource.m:68)
19 CoreFoundation 0x2234f674 -[_CFXPreferences setValue:forKey:appIdentifier:container:configurationURL:] + 108 (CFXPreferences.m:791)
20 CoreFoundation 0x224a619c _CFPreferencesSetAppValueWithContainerAndConfiguration + 132 (CFXPreferences.m:1853)
21 Foundation 0x22e55a4c -[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 64 (NSUserDefaults.m:226)
22 My App Name 0x04a55320 specialized static NSUserDefaults.lastSentToPhone.setter + 272 (UserDefaults.swift:423)
23 My App Name 0x04a500ac WatchConnectivityManager.sendBatteryLevel() + 2692 (<compiler-generated>:0)
24 My App Name 0x04a55714 #objc ExtensionDelegate.applicationWillEnterForeground() + 188 (ExtensionDelegate.swift:32)
25 WatchKit 0x34d21654 __80-[SPRemoteInterface applicationWillEnterForeground:withVisibleViewControllerID:]_block_invoke_2 + 128 (SPRemoteInterface.m:3668)
26 WatchKit 0x34d40910 -[SPRemoteInterface performAfterApplicationDidFinishLaunching:] + 56 (SPRemoteInterface.m:3713)
27 WatchKit 0x34d215c8 __80-[SPRemoteInterface applicationWillEnterForeground:withVisibleViewControllerID:]_block_invoke + 80 (SPRemoteInterface.m:3666)
28 WatchKit 0x34d3ef08 spUtils_dispatchAsyncToMainThread + 40 (SPUtils.m:347)
29 WatchKit 0x34d21444 -[SPRemoteInterface applicationWillEnterForeground:withVisibleViewControllerID:] + 212 (SPRemoteInterface.m:3665)
30 WatchKit 0x34d2135c -[SPRemoteInterface appWillEnterForeground:withVisibleViewControllerID:] + 60 (SPRemoteInterface.m:4535)
31 WatchKit 0x34d21280 __75-[SPExtensionConnection appWillEnterForegroundWithVisibleViewControllerID:]_block_invoke + 320 (SPExtensionConnection.m:1669)
32 WatchKit 0x34d3d64c -[SPExtensionConnection performOnSendQueue:syncIfUnsuspended:] + 564 (SPExtensionConnection.m:0)
33 WatchKit 0x34d2111c -[SPExtensionConnection appWillEnterForegroundWithVisibleViewControllerID:] + 112 (SPExtensionConnection.m:1667)
34 WatchKit 0x34d21010 -[SPApplicationDelegate applicationWillEnterForeground:] + 264 (SPApplicationDelegate.m:670)
35 UIKitCore 0x3f3a7ca4 -[UIApplication _sendWillEnterForegroundCallbacks] + 164 (UIApplication.m:10680)
36 UIKitCore 0x3ec6c630 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke_2 + 1748 (_UISceneLifecycleMultiplexer.m:572)
37 UIKitCore 0x3f069a5c _UIScenePerformActionsWithLifecycleActionMask + 104 (_UISceneLifecycleState.m:109)
38 UIKitCore 0x3ec6beb8 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 208 (_UISceneLifecycleMultiplexer.m:501)
39 UIKitCore 0x3ec6b8d0 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 292 (_UISceneLifecycleMultiplexer.m:450)
40 UIKitCore 0x3ec6bcc4 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 768 (_UISceneLifecycleMultiplexer.m:500)
41 UIKitCore 0x3ec6b564 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 336 (_UISceneLifecycleMultiplexer.m:406)
42 UIKitCore 0x3ec6fb50 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block... + 188 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:102)
43 UIKitCore 0x3efa7548 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 804 (BSAnimationSettings+UIKit.m:50)
44 UIKitCore 0x3f0827dc _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 244 (_UISceneSettingsDiffAction.m:43)
45 UIKitCore 0x3ec6f920 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block... + 136 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:87)
46 UIKitCore 0x3f0826d8 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 100 (_UISceneSettingsDiffAction.m:35)
47 UIKitCore 0x3ec6f78c -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 376 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:85)
48 UIKitCore 0x3eaf2b78 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 640 (UIScene.m:1340)
49 UIKitCore 0x3eaf1720 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 236 (UIScene.m:1073)
50 UIKitCore 0x3eaf28ac -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220 (UIScene.m:1317)
51 UIKitCore 0x3efc7c8c -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 464 (UIApplicationSceneClientAgent.m:80)
52 PepperUICore 0x2ebc2d94 -[PUICApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 804 (PUICApplicationSceneClientAgent.m:156)
53 CarouselUIServices 0x32abcbec -[CUISWatchKitApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 276 (CUISWatchKitApplicationSceneClientAgent.m:80)
54 FrontBoardServices 0x25ea1660 -[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:] + 528 (FBSSceneImpl.m:551)
55 FrontBoardServices 0x25ec5914 __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke_2 + 120 (FBSWorkspaceScenesClient.m:356)
56 FrontBoardServices 0x25eab12c -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232 (FBSWorkspace.m:357)
57 FrontBoardServices 0x25ec5848 __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke + 184 (FBSWorkspaceScenesClient.m:355)
58 libdispatch.dylib 0x21e44fc0 _dispatch_client_callout + 16 (object.m:495)
59 libdispatch.dylib 0x21e47cac _dispatch_block_invoke_direct + 248 (queue.c:466)
60 FrontBoardServices 0x25ee9b44 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40 (FBSSerialQueue.m:173)
61 FrontBoardServices 0x25ee9810 -[FBSSerialQueue _queue_performNextIfPossible] + 412 (FBSSerialQueue.m:216)
62 FrontBoardServices 0x25ee9d94 -[FBSSerialQueue _performNextFromRunLoopSource] + 28 (FBSSerialQueue.m:247)
63 CoreFoundation 0x223ee2f8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1922)
64 CoreFoundation 0x223ee250 __CFRunLoopDoSource0 + 80 (CFRunLoop.c:1956)
65 CoreFoundation 0x223ed9f0 __CFRunLoopDoSources0 + 184 (CFRunLoop.c:1992)
66 CoreFoundation 0x223e8adc __CFRunLoopRun + 772 (CFRunLoop.c:2882)
67 CoreFoundation 0x223e84d0 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3192)
68 GraphicsServices 0x25984358 GSEventRunModal + 160 (GSEvent.c:2246)
69 UIKitCore 0x3f392fac UIApplicationMain + 1756 (UIApplication.m:4820)
70 libxpc.dylib 0x220d9bdc _xpc_objc_main.cold.3 + 208
71 libxpc.dylib 0x220c5ccc _xpc_objc_main + 212 (main.m:0)
72 libxpc.dylib 0x220c82b0 xpc_main + 152 (init.c:1384)
73 Foundation 0x22e51738 -[NSXPCListener resume] + 160 (NSXPCListener.m:276)
74 PlugInKit 0x2bdb40a8 -[PKService run] + 396 (PKService.m:165)
75 WatchKit 0x34d39e94 WKExtensionMain + 60 (main.m:19)
76 libdyld.dylib 0x21e80f48 start + 4
Thread 1:
0 libsystem_pthread.dylib 0x22081800 start_wqthread + 0
Thread 2:
0 libsystem_pthread.dylib 0x22081800 start_wqthread + 0
Thread 3 name:
Thread 3:
0 libsystem_kernel.dylib 0x21fdb134 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x21fda604 mach_msg + 72 (mach_msg.c:103)
2 CoreFoundation 0x223edb5c __CFRunLoopServiceMachPort + 148 (CFRunLoop.c:2575)
3 CoreFoundation 0x223e8c40 __CFRunLoopRun + 1128 (CFRunLoop.c:2931)
4 CoreFoundation 0x223e84d0 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3192)
5 Foundation 0x22e1638c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 228 (NSRunLoop.m:374)
6 Foundation 0x22e1626c -[NSRunLoop(NSRunLoop) runUntilDate:] + 88 (NSRunLoop.m:421)
7 UIKitCore 0x3f4235f8 -[UIEventFetcher threadMain] + 152 (UIEventFetcher.m:733)
8 Foundation 0x22f42404 __NSThread__start__ + 844 (NSThread.m:724)
9 libsystem_pthread.dylib 0x22079984 _pthread_start + 156 (pthread.c:896)
10 libsystem_pthread.dylib 0x22081814 thread_start + 8
Thread 4 name:
Thread 4:
0 libobjc.A.dylib 0x21d8407c getMethodNoSuper_nolock(objc_class*, objc_selector*) + 168 (objc-runtime-new.mm:5813)
1 libobjc.A.dylib 0x21d8e164 lookUpImpOrForward + 348 (objc-runtime-new.mm:6221)
2 libobjc.A.dylib 0x21d7ad5c _objc_msgSend_uncached + 60
3 libobjc.A.dylib 0x21d7a588 CALLING_SOME_+initialize_METHOD + 20 (objc-initialize.mm:384)
4 libobjc.A.dylib 0x21d80140 initializeNonMetaClass + 548 (objc-initialize.mm:554)
5 libobjc.A.dylib 0x21d814d8 initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt<false>&, bool) + 272 (objc-runtime-new.mm:2183)
6 libobjc.A.dylib 0x21d8e2c8 lookUpImpOrForward + 704 (objc-runtime-new.mm:2199)
7 libobjc.A.dylib 0x21d7ad5c _objc_msgSend_uncached + 60
8 WatchConnectivity 0x3616795c -[WCQueueManager onqueue_sendMessage:completionHandler:] + 64 (WCQueueManager.m:100)
9 libdispatch.dylib 0x21e43c1c _dispatch_call_block_and_release + 24 (init.c:1408)
10 libdispatch.dylib 0x21e44fc0 _dispatch_client_callout + 16 (object.m:495)
11 libdispatch.dylib 0x21e4b128 _dispatch_lane_serial_drain + 676 (inline_internal.h:2484)
12 libdispatch.dylib 0x21e4bb08 _dispatch_lane_invoke + 404 (queue.c:3863)
13 libdispatch.dylib 0x21e5501c _dispatch_workloop_worker_thread + 584 (queue.c:6445)
14 libsystem_pthread.dylib 0x2207b704 _pthread_wqthread + 276 (pthread.c:2351)
15 libsystem_pthread.dylib 0x22081808 start_wqthread + 8
Thread 5 name:
Thread 5 Crashed:
0 CoreFoundation 0x224c58b0 _CFRelease.cold.2 + 16
1 CoreFoundation 0x223efda4 _CFRelease + 1440 (CFRuntime.c:2041)
2 libswiftCore.dylib 0x48565aa8 String.init(_cocoaString:) + 44 (<compiler-generated>:0)
3 libswiftFoundation.dylib 0x48820d94 static String._unconditionallyBridgeFromObjectiveC(_:) + 36 (String.swift:25)
4 My App Name 0x04a503f0 WatchConnectivityManager.getCurrentWatchInfo() + 424 (WatchConnectivityManager.swift:219)
5 My App Name 0x04a4f798 WatchConnectivityManager.sendWatchInfo() + 368 (WatchConnectivityManager.swift:149)
6 My App Name 0x04a508cc #objc WatchConnectivityManager.session(_:activationDidCompleteWith:error:) + 72 (WatchConnectivityManager.swift:252)
7 WatchConnectivity 0x36156f28 __57-[WCSession onqueue_completeSwitchTask:withSessionState:]_block_invoke_2 + 380 (WCSession.m:1509)
8 Foundation 0x22f1eb4c __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16 (NSOperation.m:1541)
9 Foundation 0x22e2ca00 -[NSBlockOperation main] + 84 (NSOperation.m:1560)
10 Foundation 0x22f20d80 __NSOPERATION_IS_INVOKING_MAIN__ + 20 (NSOperation.m:2184)
11 Foundation 0x22e2c6ec -[NSOperation start] + 752 (NSOperation.m:2201)
12 Foundation 0x22f21750 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 20 (NSOperation.m:2215)
13 Foundation 0x22f21230 __NSOQSchedule_f + 180 (NSOperation.m:2226)
14 libdispatch.dylib 0x21e43c1c _dispatch_call_block_and_release + 24 (init.c:1408)
15 libdispatch.dylib 0x21e44fc0 _dispatch_client_callout + 16 (object.m:495)
16 libdispatch.dylib 0x21e47700 _dispatch_continuation_pop + 496 (inline_internal.h:2484)
17 libdispatch.dylib 0x21e46e18 _dispatch_async_redirect_invoke + 588 (queue.c:803)
18 libdispatch.dylib 0x21e53cfc _dispatch_root_queue_drain + 356 (inline_internal.h:2525)
19 libdispatch.dylib 0x21e54494 _dispatch_worker_thread2 + 116 (queue.c:6628)
20 libsystem_pthread.dylib 0x2207b6c8 _pthread_wqthread + 216 (pthread.c:2364)
21 libsystem_pthread.dylib 0x22081808 start_wqthread + 8
Thread 6:
0 libsystem_pthread.dylib 0x22081800 start_wqthread + 0
Thread 7:
0 libsystem_pthread.dylib 0x22081800 start_wqthread + 0
Thread 5 crashed with ARM Thread State (64-bit):
x0: 0x0000000014ee1b10 x1: 0x0000000048c0cc97 x2: 0x0000000000005002 x3: 0x0000000000000000
x4: 0x0000000014ee1af0 x5: 0x0000000000000002 x6: 0x0000000000000000 x7: 0x0000000000000000
x8: 0x000000004fb0e000 x9: 0x0000000022533950 x10: 0x00000000153c2e00 x11: 0x000000000000003f
x12: 0x00000000153c2eb8 x13: 0x00000000001c0369 x14: 0x0000000000000000 x15: 0x000000005cd5d1ff
x16: 0x0000000050b251d8 x17: 0x000000002235c024 x18: 0x0000000000000000 x19: 0x0000000014ee1b10
x20: 0x0000000004600790 x21: 0x0000000014ee1b10 x22: 0x0000000000005002 x23: 0x0000000014d8e900
x24: 0x0000000000000001 x25: 0x0000000004a65000 x26: 0x000000000000c000 x27: 0x0000000004a65d60
x28: 0x00000000c0004002 fp: 0x00000000192ee8b0 lr: 0x00000000223efda4
sp: 0x00000000192ee840 pc: 0x00000000224c58b0 cpsr: 0x60000000
esr: 0xf2000001 Address size fault
WatchConnectivityManager class:
class WatchConnectivityManager {
static let shared = WatchConnectivityManager()
let session = WCSession.default
func sendWatchInfo() {
if session.activationState == .activated {
let name = getCurrentWatchInfo()
let message: [String : Any] = ["appleWatchName" : name]
if session.isReachable {
session.sendMessage(message,
replyHandler: nil,
errorHandler: nil)
}
do {
try session.updateApplicationContext(message)
} catch(let error) {
fatalError(error.localizedDescription)
}
}
}
private func getCurrentWatchInfo() -> String {
let name: String
name = WKInterfaceDevice.current().name
return name
}
}
Even though the API says that WKInterfaceDevice.current().name is a String instead of String?, name is somehow actually a nil value in some cases.
It can't be nil. name is a property declared as:
var name: String { get }
It can be an empty string, but not nil (Swift context). And the Objective-C:
#property(nonatomic, readonly, copy) NSString *name;
It's encapsulated with the NS_ASSUME_NONNULL_BEGIN & NS_ASSUME_NONNULL_END which effectively means:
#property(nonatomic, readonly, copy) NSString * _Nonnull safeName;
Read Nullability and Objective-C to see how it affects Objective-C -> Swift.
Actually it can be nil in the Objective-C context, but it violates the _Nonnull contract then.
As a possible solution, I'm thinking that instead of name: String I should use name: String?.
I don't think it's going to help even if you can do this. Imagine you have the following method1:
- (NSString * _Nonnull)canNotBeNilNothing {
return nil;
}
Used in Swift:
let name: String? = WKInterfaceDevice.current().canNotBeNilNothing();
print("\(String(describing: name))")
You still get the Optional(""), not nil. And it's expected, because there's this _Nonnull (it violates the contract, but it's another story).
You can create something like this if you are really sure it can return nil in Objective-C:
- (NSString * _Nullable)maybeName {
return [self name];
}
And then you can use String? in Swift and it can become nil if [self name] will return nil.
Possible causes of your problem
Bug somewhere in the WatchKit (Incorrect nullability annotation, ...)
Something else
I'm not sure what's happening, because I didn't see the stacktrace.
Possible solution
WatchKit & Objective-C problem (throws an exception)? It might be fixable with the following wrapper in Objective-C:
- (NSString * _Nullable)maybeName {
#try {
return [self name];
}
#catch (NSException *exception) {
// Return nil or handle it your way
return nil;
}
}
Bridging issue (incorrect nullability)? It might be fixable with the following code in Swift:
extension WKInterfaceDevice {
var maybeName: String? {
self.perform(#selector(getter: WKInterfaceDevice.name))?.takeRetainedValue() as! String?
}
}
1 In general, you should look at nullable and nonnull roughly the way you currently use assertions or exceptions: violating the contract is a programmer error. In particular, return values are something you control, so you should never return nil for a non-nullable return type unless it is for backwards-compatibility. (Nullability and Objective-C)
I have been working with Obj-C, Xcode from years, but at times these crash happens to a project. I have no clue how to deal with these.
If someone has any idea, please guide me towards right direction, so that I can workout.
NOTE: The following logs are sent by customer from the live app.
Snipped of crash log is;
Date/Time: 2018-02-08 16:39:36.053 +0530
OS Version: Mac OS X 10.12.6 (16G29)
Report Version: 12
Anonymous UUID: 163431E3-7543-821C-B71C-392218AA5AD3
Sleep/Wake UUID: 1D59C34E-52D6-4F57-A2CE-4C8FAC4387FE
Time Awake Since Boot: 9100 seconds
Time Since Wake: 6000 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: EXC_I386_GPFLT
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libdispatch.dylib 0x00007fffdb6ca521 _dispatch_call_block_and_release + 9
1 libdispatch.dylib 0x00007fffdb6c18fc _dispatch_client_callout + 8
2 libdispatch.dylib 0x00007fffdb6ceaac _dispatch_main_queue_callback_4CF + 925
3 com.apple.CoreFoundation 0x00007fffc5facbc9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
4 com.apple.CoreFoundation 0x00007fffc5f6dc0d __CFRunLoopRun + 2205
5 com.apple.CoreFoundation 0x00007fffc5f6d114 CFRunLoopRunSpecific + 420
6 com.apple.HIToolbox 0x00007fffc54cdebc RunCurrentEventLoopInMode + 240
7 com.apple.HIToolbox 0x00007fffc54cdcf1 ReceiveNextEventCommon + 432
8 com.apple.HIToolbox 0x00007fffc54cdb26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
9 com.apple.AppKit 0x00007fffc3a66a54 _DPSNextEvent + 1120
10 com.apple.AppKit 0x00007fffc41e27ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
11 com.apple.AppKit 0x00007fffc3a5b3db -[NSApplication run] + 926
12 com.apple.AppKit 0x00007fffc3a25e0e NSApplicationMain + 1237
13 libdyld.dylib 0x00007fffdb6f7235 start + 1
Thread 1:
0 libsystem_kernel.dylib 0x00007fffdb825bf2 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fffdb9117fa _pthread_cond_wait + 712
2 libc++.1.dylib 0x00007fffda28e4cd std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 47
3 com.apple.JavaScriptCore 0x00007fffc8f7b43c void std::__1::condition_variable_any::wait<std::__1::unique_lock<bmalloc::Mutex> >(std::__1::unique_lock<bmalloc::Mutex>&) + 108
4 com.apple.JavaScriptCore 0x00007fffc8f7b3bb bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>::threadRunLoop() + 155
5 com.apple.JavaScriptCore 0x00007fffc8f7b28d bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>::threadEntryPoint(bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>*) + 29
6 com.apple.JavaScriptCore 0x00007fffc8f7b53d void* std::__1::__thread_proxy<std::__1::tuple<void (*)(bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>*), bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>*> >(void*) + 93
7 libsystem_pthread.dylib 0x00007fffdb91093b _pthread_body + 180
8 libsystem_pthread.dylib 0x00007fffdb910887 _pthread_start + 286
9 libsystem_pthread.dylib 0x00007fffdb91008d thread_start + 13
0 libdispatch.dylib 0x00007fffdb6ca521 _dispatch_call_block_and_release + 9
1 libdispatch.dylib 0x00007fffdb6c18fc _dispatch_client_callout + 8
2 libdispatch.dylib 0x00007fffdb6ceaac _dispatch_main_queue_callback_4CF + 925
The crash is happening when GCD is trying to execute a block on the main thread. Check you callback blocks to make sure they are cleanly capturing state and that all blocks that need to be copied are copied correctly.
This is likely because there is some object captured by the block that was prematurely released or because the block itself was over-released (unlikely).
MyApp has crashed and I have collected the below crash log from that MAC book. As it is mentioned the application crashed at thread 3, I could not able to figure out what has happened,
I was suspecting it could be because of a NSTimer Lock and tryLock, but not sure how to figure it out. Crash is not happening with all MAC book but only to a certain set of users all of them are just migrated to MAC 10.10.5. But I have also other MAC book which has MAC 10.10.5 in which MyApp is running perfectly.
can anyone help me out to find the problem?
If i looked at the code at [AppMainController sendPacketForLoginStatus] + 1644
it is just a comment line just after the curly brace { starting of an else{}
if
...
else
{
<< line no: 1644>> // Change the status icon if necessary when losing the focus
[self performSelectorOnMainThread:#selector(showClickStatusIconWhenLoseFocusInThread) withObject:nil waitUntilDone:NO];
...
Crash log:
Process: MyAppAgent [581]
Path: /Applications/MyAppAgent.app/Contents/MacOS/MyAppAgent
Identifier: com.Mycmp.MyApp.MyAppAgent
Version: 1.0.0.1
Code Type: X86 (Native)
Parent Process: ??? [1]
Responsible: MyAppAgent [581]
User ID: 501
Date/Time: 2015-09-08 10:32:09.940 -0400
OS Version: Mac OS X 10.10.5 (14F27)
Crashed Thread: 3
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000022b0dd78
....
Thread 3 Crashed:
0 com.Mycmp.MyApp.MyAppAgent 0x00012a74 -[AppMainController sendPacketForLoginStatus] + 1644
1 com.Mycmp.MyApp.MyAppAgent 0x0001012c -[AppMainController timerQueryDiscovery:] + 1726
2 com.apple.Foundation 0x943ba76f __NSFireTimer + 119
3 com.apple.CoreFoundation 0x90653006 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
4 com.apple.CoreFoundation 0x90652ab4 __CFRunLoopDoTimer + 1316
5 com.apple.CoreFoundation 0x906ce54f __CFRunLoopDoTimers + 351
6 com.apple.CoreFoundation 0x9060a531 __CFRunLoopRun + 2081
7 com.apple.CoreFoundation 0x90609aa6 CFRunLoopRunSpecific + 390
8 com.apple.CoreFoundation 0x9060990b CFRunLoopRunInMode + 123
9 com.apple.Foundation 0x944043ea -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 305
10 com.apple.Foundation 0x944847fa -[NSRunLoop(NSRunLoop) run] + 76
11 com.Mycmp.MyApp.MyAppAgent 0x00002ff0 -[AppMainController threadDiscovery:] + 360
12 com.apple.Foundation 0x943acb8d -[NSThread main] + 45
13 com.apple.Foundation 0x943ac936 __NSThread__main__ + 1538
14 libsystem_pthread.dylib 0x9abfcc25 _pthread_body + 138
15 libsystem_pthread.dylib 0x9abfcb9b _pthread_start + 162
16 libsystem_pthread.dylib 0x9abf9e32 thread_start + 34
First time posting here and i'm new to this whole developer thing so please be nice!
I have submitted my app (a 3d game made in unity) and it has returned 3 crash reports, which all look pretty similar to me. I've put them through unity. I'll post one below (it was too long so i just posted the first bit) as they are so long, if you can help id be happy to post the other 2.
Any help would be greatly appreciated! Thanks!
Incident Identifier: 938FFF53-56A2-4A1D-BF23-4E24567BA101
CrashReporter Key: 3286a932eadfb6a4501de9b1e0044450b3f54fb3
Hardware Model: xxx
Process: Box [1376]
Path: /private/var/mobile/Containers/Bundle/Application/00E4561A-F30C-4C48-B2BD-355A71A4D971/Box.app/Box
Identifier: Bob.Bob
Version: 1 (1)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2015-06-02 17:16:47.033 -0700
Launch Time: 2015-06-02 17:16:42.956 -0700
OS Version: iOS 8.3 (12F69)
Report Version: 105
Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000000ff222c47
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x32123df0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x321a2cc3 pthread_kill + 59
2 libsystem_c.dylib 0x320bf905 abort + 73
3 Box 0x0182d908 mono_handle_native_sigsegv + 312
4 Box 0x0181d08c mono_sigsegv_signal_handler + 256
5 libsystem_platform.dylib 0x3219e879 _sigtramp + 41
6 Box 0x013e1f40 void ApplyMaterialPropertyBlockValuesMetal<SetValuesFunctorMetal>(MaterialPropertyBlock const&, GpuProgram*, GpuProgramParameters const*, ShaderType, SetValuesFunctorMetal&) (GpuProgramParamsApply.h:109)
7 Box 0x013de9c4 GfxDeviceMetal::SetMaterialProperties(MaterialPropertyBlock const&) (GfxDeviceMetal.mm:513)
8 Box 0x00ee48a0 ApplyBuiltinInstanceProperty::PerformFlushMaterialProperties() (ApplyBuiltinInstanceProperty.cpp:13)
9 Box 0x00f39ebc Skybox::SetupSun(Camera const&, GfxDevice&) (Skybox.cpp:256)
10 Box 0x00f3a218 Skybox::RenderSkybox(Unity::Material*, Camera const&) (Skybox.cpp:275)
11 Box 0x00ef941c Camera::RenderSkybox() (Camera.cpp:780)
12 Box 0x00ef3900 DoRenderLoop(RenderLoop&, RenderingPath, CullResults&, ShadowMapCache&, bool) (RenderLoopPrivate.cpp:416)
13 Box 0x00efa604 Camera::DoRender(CullResults&, void (*)(Camera&, RenderLoop&, CullResults&), int) (Camera.cpp:1175)
14 Box 0x00efad88 Camera::Render(CullResults&, ShaderLab::ShaderPassContext&, int) (Camera.cpp:1833)
15 Box 0x00f2c438 RenderManager::RenderCameras(int) (RenderManager.cpp:111)
16 Box 0x0104815c PlayerRender(bool) (Player.cpp:1490)
17 Box 0x01048c0c PlayerLoop(bool, bool, IHookEvent*) (Player.cpp:1990)
18 Box 0x00e13948 UnityPlayerLoopImpl(bool) (LibEntryPoint.mm:209)
19 Box 0x0008eb7c UnityRepaint (UnityAppController+Rendering.mm:199)
20 Box 0x0009e5a4 -[UnityAppController(ViewHandling) showGameUI] (UnityAppController+ViewHandling.mm:160)
21 Box 0x0009aeac -[UnityAppController startUnity:] (UnityAppController.mm:109)
22 Foundation 0x24378369 __NSFireDelayedPerform + 465
23 CoreFoundation 0x2360aedd __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 13
24 CoreFoundation 0x2360aa57 __CFRunLoopDoTimer + 647
25 CoreFoundation 0x23608ca7 __CFRunLoopRun + 1415
26 CoreFoundation 0x235551fd CFRunLoopRunSpecific + 473
27 CoreFoundation 0x2355500f CFRunLoopRunInMode + 103
28 GraphicsServices 0x2acf11fd GSEventRunModal + 133
29 UIKit 0x26cf9a55 UIApplicationMain + 1437
30 Box 0x000852b0 main (main.mm:40)
31 libdyld.dylib 0x32059aad start + 1
I have an app with HockeyApp integrated for crash reporting.
yesterday i have recieved a crash report stated below.
Incident Identifier: B797B4D3-EA8D-4226-8B0E-11149ADC20B7
CrashReporter Key: 55E9EBD1-9990-44EF-98E8-C0A000955CED
Hardware Model: iPhone5,2
Process: AppName [1375]
Path: /Users/USER/AppName.app/AppName
Identifier: ----------------------------
Version: 1.0.0
Code Type: ARM
Parent Process: launchd [1]
Date/Time: 2013-10-21T18:04:47Z
OS Version: iPhone OS 7.0.2 (11A501)
Report Version: 104
Exception Type: SIGABRT
Exception Codes: #0 at 0x38f341fc
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
Last Exception Backtrace:
0 CoreFoundation 0x2e689e8b <redacted> + 131
1 libobjc.A.dylib 0x389846c7 _objc_exception_throw + 39
2 CoreFoundation 0x2e5bfe65 <redacted> + 233
3 AppName 0x000ac04d 0x66000 + 286797
4 AppName 0x000abf17 0x66000 + 286487
5 Foundation 0x2f06ee6d ___NSFireTimer + 65
6 CoreFoundation 0x2e654e87 <redacted> + 15
7 CoreFoundation 0x2e654aa3 <redacted> + 795
8 CoreFoundation 0x2e652e2b <redacted> + 1219
9 CoreFoundation 0x2e5bd541 _CFRunLoopRunSpecific + 525
10 CoreFoundation 0x2e5bd323 _CFRunLoopRunInMode + 107
11 GraphicsServices 0x332f42eb _GSEventRunModal + 139
12 UIKit 0x30e741e5 _UIApplicationMain + 1137
13 AppName 0x000b6cd7 0x66000 + 330967
14 libdyld.dylib 0x38e7dab7 <redacted> + 3
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x38f341fc ___pthread_kill + 8
1 libsystem_c.dylib 0x38ee502d _abort + 77
2 AppName 0x000e41ff 0x66000 + 516607
3 CoreFoundation 0x2e68a18d <redacted> + 581
4 libobjc.A.dylib 0x38984927 <redacted> + 175
5 libc++abi.dylib 0x3834a1b3 <redacted> + 79
6 libc++abi.dylib 0x38349d17 ___cxa_rethrow + 103
7 libobjc.A.dylib 0x3898480f _objc_exception_rethrow + 43
8 CoreFoundation 0x2e5bd5b7 _CFRunLoopRunSpecific + 643
9 CoreFoundation 0x2e5bd323 _CFRunLoopRunInMode + 107
10 GraphicsServices 0x332f42eb _GSEventRunModal + 139
11 UIKit 0x30e741e5 _UIApplicationMain + 1137
12 AppName 0x000b6cd7 0x66000 + 330967
Thread 1:
0 libsystem_kernel.dylib 0x38f21838 _kevent64 + 24
1 libdispatch.dylib 0x38e6a643 <redacted> + 39
Thread 2:
0 libsystem_kernel.dylib 0x38f33f38 ___psynch_cvwait + 24
1 libsystem_pthread.dylib 0x38f9b041 _pthread_cond_wait + 41
2 Foundation 0x2eff874f <redacted> + 195
3 AppName 0x0011a5a1 0x66000 + 738721
4 Foundation 0x2f06ddc7 <redacted> + 1063
5 libsystem_pthread.dylib 0x38f9ac5d <redacted> + 141
6 libsystem_pthread.dylib 0x38f9abcf __pthread_start + 103
Thread 3:
0 libsystem_kernel.dylib 0x38f21a84 _mach_msg_trap + 20
1 CoreFoundation 0x2e654561 <redacted> + 157
2 CoreFoundation 0x2e652c81 <redacted> + 793
3 CoreFoundation 0x2e5bd541 _CFRunLoopRunSpecific + 525
4 CoreFoundation 0x2e5bd323 _CFRunLoopRunInMode + 107
5 Foundation 0x2efab827 <redacted> + 255
6 Foundation 0x2effc669 <redacted> + 81
7 AppName 0x00138e95 0x66000 + 863893
8 Foundation 0x2f06ddc7 <redacted> + 1063
9 libsystem_pthread.dylib 0x38f9ac5d <redacted> + 141
10 libsystem_pthread.dylib 0x38f9abcf __pthread_start + 103
Thread 4:
0 libsystem_kernel.dylib 0x38f21a84 _mach_msg_trap + 20
1 CoreFoundation 0x2e654561 <redacted> + 157
2 CoreFoundation 0x2e652c81 <redacted> + 793
3 CoreFoundation 0x2e5bd541 _CFRunLoopRunSpecific + 525
4 CoreFoundation 0x2e5bd323 _CFRunLoopRunInMode + 107
5 Foundation 0x2eff8651 <redacted> + 321
6 Foundation 0x2f06ddc7 <redacted> + 1063
7 libsystem_pthread.dylib 0x38f9ac5d <redacted> + 141
8 libsystem_pthread.dylib 0x38f9abcf __pthread_start + 103
Thread 5:
0 libsystem_kernel.dylib 0x38f34440 ___select + 20
1 libsystem_pthread.dylib 0x38f9ac5d <redacted> + 141
2 libsystem_pthread.dylib 0x38f9abcf __pthread_start + 103
Thread 6:
0 libsystem_kernel.dylib 0x38f34c7c ___workq_kernreturn + 8
Thread 7:
0 libsystem_kernel.dylib 0x38f34c7c ___workq_kernreturn + 8
Thread 0 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x00000000 r2: 0x00000000 r3: 0xffffffff
r4: 0x00000006 r5: 0x3ad6118c r6: 0x17e19650 r7: 0x27d9d924
r8: 0x3140f0da r9: 0x3ad61e30 r10: 0x313f4457 r11: 0x0000000f
ip: 0x00000148 sp: 0x27d9d918 lr: 0x38f9ba53 pc: 0x38f341fc
cpsr: 0x00000010
It's saying that crash is occured on Thread 0 but when i run the app from Xcode, debugger does not show any thread 0 and starts threds from 1 and so on. I am unable to produce this crash.
How can i demystify the crash and where it is heppeing.
you got a reason:
* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for
empty array'
You are somewhere trying to access the first element of an empty array.
Doesn't really matter which thread crashed