Retain property and EXC_BAD_ACCESS on NSArray - objective-c

I have gone through all the relevant posts on EXC_BAD_ACCESS but failed to have the concept clear yet. Maybe I should first work on learning the basic concepts but right now I need to get on this issue.. So, stepped in to get some expert help..
Here is my code (I have pasted only the relevant part)
//In .h
//=====
#interface GUIMainController : GUIController {
::
::
NSArray* shufflePositionArray;
}
#property (retain)NSArray* shufflePositionArray;
//In .mm
//=======
#synthesize shufflePositionArray;
-(void)start
{
::
NSString* shufflePositionArrayPlistPath=nil;
NSString* shufflePositionArrayPlistPathFromConfiguration=
#"/MyApp/Configuration/ShufflePositionArray.plist";
if ([[NSFileMngrdfltMngr]fileExistsAtPath:shufflePositionArrayPlistPathFromConfig])
{
self.shufflePositionArray=
[NSArrayarrayWithContentsOfFile:shufflePositionArrayPlistPathFromConfig];
}
if (self.shufflePositionArray==nil) {
shufflePositionArrayPlistPath=
[thisBundle pathForResource:#"ShufflePositionArray" ofType:#"plist"];
if (shufflePositionArrayPlistPath!=nil) {
self.shufflePositionArray=
[NSArray arrayWithContentsOfFile:shufflePositionArrayPlistPath];
}
}
}
//From another method:
//====================
-(void)shuffleWindow
{
::
if (shufflePositionArray!=nil && [self.shufflePositionArray count]!=0){
:: // some code
if (shufflePositionArray!=nil && [self.shufflePositionArray count]!=0){
::
:: // some code
processwindowlocation_=(processwindowlocation_+1)%[self.shufflePositionArray count];
// ######## there is a crash here !!!!!! #############
}
}
}
//And then..we release it here:
//==============================
-(void)dealloc {
if(shufflePositionArray!=nil){
[shufflePositionArray release];
}
[super dealloc];
}
I am completely new to obj-C, any sort of help would be appreciated.
Thanks in advance.
Here is the crash:
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000018
VM Regions Near 0x18:
-->
__TEXT 000000010d89a000-000000010d927000 [ 564K] r-x/rwx SM=COW /Ihome/MyAppCE.app/Contents/MacOS/MyAppCE
Application Specific Information:
objc_msgSend() selector name: count
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x00007fff82c5d62f objc_msgSend_vtable9 + 47
1 com.apple.AppKit 0x00007fff88842b05 +[NSScreen screens] + 847
2 com.apple.AppKit 0x00007fff88844575 +[NSScreen _zeroScreenHeight] + 44
3 com.apple.AppKit 0x00007fff888b15cf _NSShapeRoundedWindowWithWeighting + 61
4 com.apple.AppKit 0x00007fff888507c3 -[NSThemeFrame shapeWindow] + 336
5 com.apple.AppKit 0x00007fff888b055c -[NSThemeFrame setFrameSize:] + 457
6 com.apple.AppKit 0x00007fff888af68f -[NSWindow _setFrame:updateBorderViewSize:] + 929
7 com.apple.AppKit 0x00007fff888aee04 -[NSWindow _oldPlaceWindow:] + 1142
8 com.apple.AppKit 0x00007fff888ae2b9 -[NSWindow _setFrameCommon:display:stashSize:] + 1837
9 com.Apple.Phoenix.UI 0x0000000110580045 -[GUIMainController shuffleWindow] + 1477 (GUIMainController.mm:470)
10 com.Apple.Phoenix.UI 0x0000000110586aef -[GUIPeriodicController periodic:] + 2399 (GUIPeriodicController.mm:219)
11 com.apple.Foundation 0x00007fff86867463 __NSFireTimer + 96
12 com.apple.CoreFoundation 0x00007fff81df5804 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
13 com.apple.CoreFoundation 0x00007fff81df531d __CFRunLoopDoTimer + 557
14 com.apple.CoreFoundation 0x00007fff81ddaad9 __CFRunLoopRun + 1529
15 com.apple.CoreFoundation 0x00007fff81dda0e2 CFRunLoopRunSpecific + 290
16 com.apple.HIToolbox 0x00007fff83dc6eb4 RunCurrentEventLoopInMode + 209
17 com.apple.HIToolbox 0x00007fff83dc6b94 ReceiveNextEventCommon + 166
18 com.apple.HIToolbox 0x00007fff83dc6ae3 BlockUntilNextEventMatchingListInMode + 62
19 com.apple.AppKit 0x00007fff8887f533 _DPSNextEvent + 685
20 com.apple.AppKit 0x00007fff8887edf2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
21 com.Apple.Phoenix.UI 0x0000000110594b52 processUIEvent() + 290 (PhoenixCECocoaGUI.mm:363)
22 com.Apple.Phoenix.UI 0x000000011058e152 Phoenix::Core::UICocoaImpl::processEvent() + 44 (UICocoaImpl.mm:61)
23 com.Apple.MyAppCE 0x000000010d8ae62e main + 2302 (mainer.cpp:180)
24 com.Apple.MyAppCE 0x000000010d89b604 start + 52
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x000000000000000f rbx: 0xffffffffffffffff rcx: 0x0000000001010101 rdx: 0x0000000000000001
rdi: 0xffffffffffffffff rsi: 0x00007fff7268ea80 rbp: 0x00007fff523631b0 rsp: 0x00007fff52363028
r8: 0x00007fff72435a30 r9: 0x00007fff72435a01 r10: 0x0000000000000000 r11: 0x00007f968c000600
r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x0000000000000001 r15: 0x000000000000000c
rip: 0x00007fff82c5d62f rfl: 0x0000000000010206 cr2: 0x0000000000000018

If you have a crash, post the backtrace.
Assuming you haven't cut out some relevant code, the only way that processwindowlocation_=(processwindowlocation_+1)%[self.shufflePositionArray count]; could crash (assuming that that is actually the line of the crash) is if either self is invalid or the shufflePositionArray is invalid.
Note that invalid does not mean nil; nil would just return 0 for the count.
Note, also, that the check for non-nil here is pointless:
if(shufflePositionArray!=nil){
[shufflePositionArray release];
}
That crash is odd. I wouldn't really expect a crash there given your code.
Try turning on Zombie detection (Instruments -- Google can find more info, if you need) and seeing if it is an over-release issue.

Related

How can I solve unconditionallyBridgeFromObjectiveC crash when storing a String value? (WKInterfaceDevice.current().name)

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)

Objective c dispatch_async crash

code :
- (void)stopCurrentSessionFromSuite:(NSNotification*)notification{
isCloseCurrentSession = YES;
dispatch_async(self.dataSendingQueue, ^{
CARD8 messageToDisableSession = rpcHostDisableMsg;
[readerNwriter writeExact:(char*)&messageToDisableSession ofLenght:sizeof(CARD8) secApplied:NO];
});
[rpcCaptureMgr stopCaptureSession];
}
Crash :
Time Awake Since Boot: 1400 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes:
KERN_INVALID_ADDRESS at 0x0000000000000070 Exception Note:
EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11 Termination Reason:
Namespace SIGNAL, Code 0xb Terminating Process: exc handler [0]
VM Regions Near 0x70:
-->
__TEXT 000000010871a000-000000010873a000 [ 128K] r-x/rwx SM=COW
/Applications/RemotePCSuite/*/RemotePCDesktop.app/Contents/MacOS/RemotePCDesktop
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0
libdispatch.dylib 0x00007fff72de50db
_dispatch_continuation_async + 5 1 com.prosoftnet.remotepcDesktop 0x0000000108727fd5
-[RPCDesktopAppDelegate stopCurrentSessionFromSuite:] + 104 2 com.apple.CoreFoundation 0x00007fff4b7a333c
CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 12 3 com.apple.CoreFoundation 0x00007fff4b7a32cf
_CFXRegistrationPost_block_invoke + 63 4 com.apple.CoreFoundation 0x00007fff4b7ab92c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 12 5
com.apple.CoreFoundation 0x00007fff4b78e8a3 __CFRunLoopDoBlocks
+ 275 6 com.apple.CoreFoundation 0x00007fff4b78e668 __CFRunLoopRun + 3128 7 com.apple.CoreFoundation 0x00007fff4b78d797 CFRunLoopRunSpecific + 487 8 com.apple.HIToolbox
0x00007fff4aaa2866 RunCurrentEventLoopInMode + 286 9
com.apple.HIToolbox 0x00007fff4aaa25d6
ReceiveNextEventCommon + 613 10 com.apple.HIToolbox
0x00007fff4aaa2354 _BlockUntilNextEventMatchingListInModeWithFilter +
64 11 com.apple.AppKit 0x00007fff48d9fa23 _DPSNextEvent
+ 2085 12 com.apple.AppKit 0x00007fff49534e6c -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044 13 com.apple.AppKit 0x00007fff48d94831 -[NSApplication run]
+ 764 14 com.apple.AppKit 0x00007fff48d639d2 NSApplicationMain + 804 15 libdyld.dylib
0x00007fff72e0c145 start + 1

CEF crashes on closing NSWindow in Macbook PRO(Only on Touchpad not for mouse click)

I have integrated CEF Framework into my project.
Its working fine for mouse based window close but it crashes If I use inbuilt touch pad of mac book pro while closing browser pop up window.
The pop up window is generate by CEF.
I am able to reproduce the crash like above most of the times.
Here is the crash log
Process: cefclient [1271] Path:
/Users/USER/Documents/*/cefclient.app/Contents/MacOS/cefclient
Identifier: com.genband.omni.mac Version:
1.0.0.30 (1.0.0.30) Code Type: X86-64 (Native) Parent Process: ??? [1] Responsible: cefclient [1271] User
ID: 501
Date/Time: 2016-07-07 14:54:14.865 +0530 OS Version:
Mac OS X 10.10.2 (14C1514) Report Version: 11 Anonymous UUID:
0F54FCED-4D82-FEB9-5CD2-3A541BF3C022
Sleep/Wake UUID: C774E441-04B7-4295-A913-3AD622E6B6F3
Time Awake Since Boot: 4300 seconds Time Since Wake: 710 seconds
Crashed Thread: 0 CrBrowserMain Dispatch queue:
com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes:
KERN_INVALID_ADDRESS at 0x0000443e46cfbec0
VM Regions Near 0x443e46cfbec0:
mapped file 0000000124936000-0000000124b36000 [ 2048K] rw-/rwx SM=ALI /private/var/folders//.3KjSNY
-->
MALLOC_NANO 0000600000000000-0000600000200000 [ 2048K] rw-/rwx SM=PRV
Application Specific Information: objc_msgSend() selector name:
respondsToSelector: Performing #selector(_close:) from sender
_NSThemeCloseWidget 0x608000186320
Thread 0 Crashed:: CrBrowserMain Dispatch queue:
com.apple.main-thread 0 libobjc.A.dylib
0x00007fff9303f0dd objc_msgSend + 29 1 com.apple.AppKit
0x00007fff87802735 -[NSWindow close] + 312 2 libsystem_trace.dylib
0x00007fff84178cd7 _os_activity_initiate + 75 3 com.apple.AppKit
0x00007fff877b9b71 -[NSApplication sendAction:to:from:] + 452 4
com.apple.AppKit 0x00007fff877b9970 -[NSControl
sendAction:to:] + 86 5 com.apple.AppKit
0x00007fff8798f86c __26-[NSCell _sendActionFrom:]_block_invoke + 131 6
libsystem_trace.dylib 0x00007fff84178cd7
_os_activity_initiate + 75 7 com.apple.AppKit 0x00007fff87802509 -[NSCell _sendActionFrom:] + 144 8
libsystem_trace.dylib 0x00007fff84178cd7
_os_activity_initiate + 75 9 com.apple.AppKit 0x00007fff87801d66 -[NSButtonCell performClick:] + 1027 10
com.apple.Foundation 0x00007fff83eaecdc
__NSThreadPerformPerform + 293 11 com.apple.CoreFoundation 0x00007fff90285681
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 12 com.apple.CoreFoundation 0x00007fff902778dc
__CFRunLoopDoSources0 + 476 13 com.apple.CoreFoundation 0x00007fff90276e3f __CFRunLoopRun + 927 14 com.apple.CoreFoundation
0x00007fff90276858 CFRunLoopRunSpecific + 296 15 com.apple.HIToolbox
0x00007fff8ab26aef RunCurrentEventLoopInMode + 235 16
com.apple.HIToolbox 0x00007fff8ab2686a
ReceiveNextEventCommon + 431 17 com.apple.HIToolbox
0x00007fff8ab266ab _BlockUntilNextEventMatchingListInModeWithFilter +
71 18 com.apple.AppKit 0x00007fff875eaf81
_DPSNextEvent + 964 19 com.apple.AppKit 0x00007fff875ea730 -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] + 194 20
com.apple.AppKit 0x00007fff875de593 -[NSApplication
run] + 594 21 org.chromium.ContentShell.framework 0x000000010d1b7c81
0x10d080000 + 1277057 22 org.chromium.ContentShell.framework
0x000000010d1b72e4 0x10d080000 + 1274596 23
org.chromium.ContentShell.framework 0x000000010d1ef893 0x10d080000 +
1505427 24 org.chromium.ContentShell.framework 0x000000010d1dd80d
0x10d080000 + 1431565 25 com.genband.omni.mac
0x000000010ceb9d69 client::MainMessageLoopStd::Run() + 9
(main_message_loop_std.cc:15) 26 com.genband.omni.mac
0x000000010cee6c12 main + 2354 (cefclient_mac.mm:1747) 27
libdyld.dylib 0x00007fff8433d5c9 start + 1
Any suggestions are highly welcome
Changing the window_ delegate to nil, in dealloc method of root_window_mac.mm cleared the crash problem for me.

Application crashes unless run from Xcode

I have this code:
NSColor *color = [NSColor colorWithDeviceHue:hue
saturation:saturation
brightness:brightness
alpha:1.0];
NSString *scriptString = [NSString stringWithFormat:
#"try\n"
#"tell application \"Adobe Photoshop CS5\" \n"
#"set foreground color to {class:RGB color, red:%f, green:%f, blue:%f} \n"
#"end tell\n"
#"on error\n"
#"try\n"
#"tell application \"Adobe Photoshop CS4\" \n"
#"set foreground color to {class:RGB color, red:%f, green:%f, blue:%f} \n"
#"end tell\n"
#"end try\n"
#"end try",
[color redComponent] * 255,
[color greenComponent] * 255,
[color blueComponent] * 255];
NSLog(#"script string: %#", scriptString);
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:scriptString];
NSDictionary *error;
[script executeAndReturnError:&error];
NSLog(#"result: %#", error);
When I run it from xcode's run feature, it works just fine. When I build it as an application and run it standalone, it quite often crashes in this part.
Any idea why this might be?
EDIT: Most of the crash log (can't fit it all in here)
Process: The Color Picker Sync [1283]
Path: /Users/USER/*/The Color Picker Sync.app/Contents/MacOS/The Color Picker Sync
Identifier: com.Loupe.The-Color-Picker-Sync
Version: 1.1 (1.1)
Code Type: X86-64 (Native)
Parent Process: launchd [160]
Date/Time: 2012-01-21 14:04:54.025 +0000
OS Version: Mac OS X 10.7.2 (11C74)
Report Version: 9
Sleep/Wake UUID: 6BFBE167-51ED-433B-BB70-17D6C4054817
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: 0x000000000000000d, 0x0000000000000000
VM Regions Near 0:
-->
__TEXT 0000000101782000-000000010178c000 [ 40K] r-x/rwx SM=COW /Users/USER/*/The Color Picker Sync.app/Contents/MacOS/The Color Picker Sync
Application Specific Information:
objc_msgSend() selector name: respondsToSelector:
objc[1283]: garbage collection is OFF
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x00007fff90d8114d objc_msgSend_vtable5 + 13
1 com.apple.Foundation 0x00007fff8c239456 _NSDescriptionWithLocaleFunc + 50
2 com.apple.CoreFoundation 0x00007fff911284d5 __CFStringAppendFormatCore + 11365
3 com.apple.CoreFoundation 0x00007fff9117acdb _CFStringCreateWithFormatAndArgumentsAux + 107
4 com.apple.CoreFoundation 0x00007fff911f3182 _CFLogvEx + 114
5 com.apple.Foundation 0x00007fff8c2b3b53 NSLogv + 89
6 com.apple.Foundation 0x00007fff8c2b3af1 NSLog + 130
7 com.Loupe.The-Color-Picker-Sync 0x0000000101784103 -[StatusMenuItemSampleAppDelegate didReceiveMessage:] + 1023 (StatusMenuItemSampleAppDelegate.m:294)
8 com.Loupe.The-Color-Picker-Sync 0x00000001017848fb -[LocalRoom receivedNetworkPacket:viaConnection:] + 104 (LocalRoom.m:161)
9 com.Loupe.The-Color-Picker-Sync 0x0000000101785aa2 -[NetworkConnection readFromStreamIntoIncomingBuffer] + 416 (NetworkConnection.m:359)
10 com.apple.CoreFoundation 0x00007fff91183b7b _signalEventSync + 107
11 com.apple.CoreFoundation 0x00007fff91183b02 _cfstream_solo_signalEventSync + 98
12 com.apple.CoreFoundation 0x00007fff91183928 _CFStreamSignalEvent + 632
13 com.apple.CFNetwork 0x00007fff87459613 SocketStream::dispatchSignalFromSocketCallbackUnlocked(SocketStreamSignalHolder*) + 45
14 com.apple.CFNetwork 0x00007fff87458c72 SocketStream::socketCallback(__CFSocket*, unsigned long, __CFData const*, void const*) + 232
15 com.apple.CFNetwork 0x00007fff87458b72 SocketStream::_SocketCallBack_stream(__CFSocket*, unsigned long, __CFData const*, void const*, void*) + 100
16 com.apple.CoreFoundation 0x00007fff9117b714 __CFSocketPerformV0 + 980
17 com.apple.CoreFoundation 0x00007fff91133b51 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
18 com.apple.CoreFoundation 0x00007fff911333bd __CFRunLoopDoSources0 + 253
19 com.apple.CoreFoundation 0x00007fff9115a1a9 __CFRunLoopRun + 905
20 com.apple.CoreFoundation 0x00007fff91159ae6 CFRunLoopRunSpecific + 230
21 com.apple.HIToolbox 0x00007fff8e14d3d3 RunCurrentEventLoopInMode + 277
22 com.apple.HIToolbox 0x00007fff8e15463d ReceiveNextEventCommon + 355
23 com.apple.HIToolbox 0x00007fff8e1544ca BlockUntilNextEventMatchingListInMode + 62
24 com.apple.AppKit 0x00007fff8c5533f1 _DPSNextEvent + 659
25 com.apple.AppKit 0x00007fff8c552cf5 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
26 com.apple.AppKit 0x00007fff8c54f62d -[NSApplication run] + 470
27 com.apple.AppKit 0x00007fff8c7ce80c NSApplicationMain + 867
28 com.Loupe.The-Color-Picker-Sync 0x000000010178302c 0x101782000 + 4140
Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff8b3cc7e6 kevent + 10
1 libdispatch.dylib 0x00007fff8bf615be _dispatch_mgr_invoke + 923
2 libdispatch.dylib 0x00007fff8bf6014e _dispatch_mgr_thread + 54
Thread 2:: com.apple.CFSocket.private
0 libsystem_kernel.dylib 0x00007fff8b3cbdf2 __select + 10
1 com.apple.CoreFoundation 0x00007fff911a2f9b __CFSocketManager + 1355
2 libsystem_c.dylib 0x00007fff90aad8bf _pthread_start + 335
3 libsystem_c.dylib 0x00007fff90ab0b75 thread_start + 13
Thread 3:
0 libsystem_kernel.dylib 0x00007fff8b3cc192 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff90aaf594 _pthread_wqthread + 758
2 libsystem_c.dylib 0x00007fff90ab0b85 start_wqthread + 13
Thread 4:
0 libsystem_kernel.dylib 0x00007fff8b3cc192 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff90aaf594 _pthread_wqthread + 758
2 libsystem_c.dylib 0x00007fff90ab0b85 start_wqthread + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x0000000000000000 rcx: 0x00007fff6137ec80 rdx: 0x00007fff8c481ccc
rdi: 0x20200a3b31203d20 rsi: 0x00007fff76a0f730 rbp: 0x00007fff6137e970 rsp: 0x00007fff6137e958
r8: 0x000000000000000a r9: 0x000000000000057e r10: 0x0000000000000000 r11: 0x00007fca58557e21
r12: 0x00007fff91128644 r13: 0x000000000000000a r14: 0x20200a3b31203d20 r15: 0x0000000000000000
rip: 0x00007fff90d8114d rfl: 0x0000000000010246 cr2: 0x000000006a86fdc0
Logical CPU: 1
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 11
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 4860
thread_create: 1
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=211.3M resident=105.4M(50%) swapped_out_or_unallocated=105.9M(50%)
Writable regions: Total=48.2M written=3504K(7%) resident=19.3M(40%) swapped_out=1856K(4%) unallocated=29.0M(60%)
REGION TYPE VIRTUAL
=========== =======
CG backing stores 8K
CG raster data 64K
CG shared images 168K
CoreGraphics 16K
CoreServices 2004K
MALLOC 22.0M
MALLOC guard page 32K
Memory tag=240 4K
Memory tag=242 12K
Memory tag=243 16K
Memory tag=249 156K
STACK GUARD 56.0M
Stack 9820K
VM_ALLOCATE 16.1M
__CI_BITMAP 80K
__DATA 21.8M
__IMAGE 1256K
__LINKEDIT 47.6M
__RC_CAMERAS 236K
__TEXT 163.7M
__UNICODE 544K
mapped file 17.1M
shared memory 312K
=========== =======
TOTAL 358.7M
The most common mistake: NSAppleScript can only be used in the main app thread because it shares a AppleScript ComponentInstance. But if you show up crash log it helps.
You need to set error to nil initially:
NSDictionary *error = nil;
[script executeAndReturnError:&error] will change the value of error only if it fails. That's why you get a bad access if there's no error.

NSTextField binding causes EXC_BAD_ACCESS

I have an NSTextField which is bound to an int in an object that I have included in my nib. When the object changes its int, the text field follows suit, and everything looks fine.
However, when I try to change it manually the program crashes as soon as I hit a key. It's not even getting into my setter methods, it just crashes with
Program received signal: “EXC_BAD_ACCESS”.
It's not even in any of my code... presumably, I made the binding wrong, but what could I have done that would make it segfault like that?
ETA: stackframes from a crash:
Process: DocKeep [77998]
Path: /Users/acordex/Documents/projects/DocKeep/build/Debug/DocKeep.app/Contents/MacOS/DocKeep
Identifier: com.acordex.DocKeep
Version: 9.00 pre-Alpha (9.00 pre-Alpha)
Code Type: X86 (Native)
Parent Process: Instruments [77954]
Date/Time: 2010-07-29 10:01:11.927 -0400
OS Version: Mac OS X 10.6.4 (10F569)
Report Version: 6
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x000000000000001c
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 com.apple.AppKit 0x954a4734 -[NSDocument(NSEditorRegistration) _isBeingEdited] + 24
1 com.apple.AppKit 0x954a4707 -[NSDocument isDocumentEdited] + 47
2 com.apple.AppKit 0x955b3900 -[NSDocument(NSEditorRegistration) objectDidBeginEditing:] + 48
3 com.apple.AppKit 0x95461ef9 -[NSValueBinder _startChanging] + 126
4 com.apple.AppKit 0x95461dc1 -[NSTextValueBinder _startChanging] + 60
5 com.apple.AppKit 0x95461d5f -[_NSBindingAdaptor _editor:didChangeEditingState:bindingAdaptor:] + 181
6 com.apple.AppKit 0x95461c9f -[_NSBindingAdaptor editorDidBeginEditing:] + 278
7 com.apple.AppKit 0x95442e5a -[NSTextField textShouldBeginEditing:] + 239
8 com.apple.AppKit 0x95441d0b -[NSTextView(NSSharing) shouldChangeTextInRanges:replacementStrings:] + 573
9 com.apple.AppKit 0x95464563 _NSDoUserReplaceForCharRange + 191
10 com.apple.AppKit 0x9546449e _NSDoUserDeleteForCharRange + 79
11 com.apple.AppKit 0x95463b07 -[NSTextView(NSKeyBindingCommands) deleteBackward:] + 684
12 com.apple.AppKit 0x9544b364 -[NSResponder doCommandBySelector:] + 77
13 com.apple.AppKit 0x9544ac7f -[NSTextView doCommandBySelector:] + 240
14 com.apple.AppKit 0x95439bbf -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] + 1911
15 com.apple.AppKit 0x9543d44f -[NSTextInputContext handleEvent:] + 1604
16 com.apple.AppKit 0x95439229 -[NSView interpretKeyEvents:] + 209
17 com.apple.AppKit 0x9543ccd5 -[NSTextView keyDown:] + 751
18 com.apple.AppKit 0x9536df6c -[NSWindow sendEvent:] + 5757
19 com.apple.AppKit 0x95286aff -[NSApplication sendEvent:] + 6431
20 com.apple.AppKit 0x9521a5bb -[NSApplication run] + 917
21 com.apple.AppKit 0x952125ed NSApplicationMain + 574
22 com.acordex.DocKeep 0x0000224c main + 30 (main.m:14)
23 com.acordex.DocKeep 0x00002202 start + 54
Thread 1:
0 libSystem.B.dylib 0x94a319d2 __workq_kernreturn + 10
1 libSystem.B.dylib 0x94a31f68 _pthread_wqthread + 941
2 libSystem.B.dylib 0x94a31b86 start_wqthread + 30
Thread 2: Dispatch queue: com.apple.libdispatch-manager
0 libSystem.B.dylib 0x94a32942 kevent + 10
1 libSystem.B.dylib 0x94a3305c _dispatch_mgr_invoke + 215
2 libSystem.B.dylib 0x94a32519 _dispatch_queue_invoke + 163
3 libSystem.B.dylib 0x94a322be _dispatch_worker_thread2 + 240
4 libSystem.B.dylib 0x94a31d41 _pthread_wqthread + 390
5 libSystem.B.dylib 0x94a31b86 start_wqthread + 30
Thread 3:
0 libSystem.B.dylib 0x94a3a066 __semwait_signal + 10
1 libSystem.B.dylib 0x94a39d22 _pthread_cond_wait + 1191
2 libSystem.B.dylib 0x94a3b9b8 pthread_cond_wait$UNIX2003 + 73
3 com.apple.CoreVideo 0x96730c3e CVDisplayLink::runIOThread() + 1016
4 com.apple.CoreVideo 0x9673082a startIOThread(void*) + 156
5 libSystem.B.dylib 0x94a3981d _pthread_start + 345
6 libSystem.B.dylib 0x94a396a2 thread_start + 34
Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x00000000 ebx: 0x954a472d ecx: 0x00000001 edx: 0x00000000
edi: 0x0045f650 esi: 0x0045f650 ebp: 0xbfffe738 esp: 0xbfffe720
ss: 0x0000001f efl: 0x00010282 eip: 0x954a4734 cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037
cr2: 0x0000001c
I DO have a document class that is subclassed off of NSDocument, and the textfield IS bound to a field of that document object, but I'm not sure why that would matter.
The environment variable NSBindingDebugLogLevel might be useful. Set it and check your logs carefully for warnings. You might not see the warning if you have a breakpoint set on NSException raise.
Bindings should work with an int, definitely not with an unsigned int. But NSTextfield requires an NSString, or at least an NSNumber and an associated NSNumberFormatter.