Crash in background- Sprite-Kit related - crash

As the title says- my Sprite Kit game crashes every now and then in background, always with this error-
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000001
Triggered by Thread: 0
Thread 0 Crashed:
0 libGPUSupportMercury.dylib 0x3220193a gpus_ReturnNotPermittedKillClient + 10
1 libGPUSupportMercury.dylib 0x322023d4 gpusSubmitDataBuffers + 100
2 IMGSGX543RC2GLDriver 0x2c6211c4 SubmitPackets + 120
3 GLEngine 0x2fb3bcda gliPresentViewES + 162
4 OpenGLES 0x2fb46134 -[EAGLContext presentRenderbuffer:] + 60
5 SpriteKit 0x2ffb0060 -[SKView _renderContent] + 1216
6 libdispatch.dylib 0x381120ec _dispatch_client_callout + 20
7 libdispatch.dylib 0x381168f6 _dispatch_barrier_sync_f_invoke + 22
8 SpriteKit 0x2ffafb6e -[SKView renderContent] + 78
9 SpriteKit 0x2ffad516 __29-[SKView setUpRenderCallback]_block_invoke + 126
10 SpriteKit 0x2ffcfc84 -[SKDisplayLink _callbackForNextFrame:] + 252
11 QuartzCore 0x2fd9003e CA::Display::DisplayLinkItem::dispatch() + 94
12 QuartzCore 0x2fd8fde8 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 340
13 IOMobileFramebuffer 0x329b876a IOMobileFramebufferVsyncNotifyFunc + 102
14 IOKit 0x2e614e6a IODispatchCalloutFromCFMessage + 246
15 CoreFoundation 0x2d8f2b86 __CFMachPortPerform + 134
16 CoreFoundation 0x2d8fd77c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
17 CoreFoundation 0x2d8fd716 __CFRunLoopDoSource1 + 342
18 CoreFoundation 0x2d8fbee2 __CFRunLoopRun + 1402
19 CoreFoundation 0x2d86653c CFRunLoopRunSpecific + 520
20 CoreFoundation 0x2d86631e CFRunLoopRunInMode + 102
21 GraphicsServices 0x3259d2e6 GSEventRunModal + 134
22 UIKit 0x3011d1e0 UIApplicationMain + 1132
23 NoCar7 0x0010c186 0xf9000 + 78214
24 libdyld.dylib 0x38126ab4 start + 0
Thread 1:
0 libsystem_kernel.dylib 0x381ca838 kevent64 + 24
1 libdispatch.dylib 0x381190d0 _dispatch_mgr_invoke + 228
2 libdispatch.dylib 0x3811363e _dispatch_mgr_thread + 34
Thread 2:
0 libsystem_kernel.dylib 0x381ddc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38241e06 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38241cc0 start_wqthread + 4
Thread 3:
0 libsystem_kernel.dylib 0x381ddc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38241e06 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38241cc0 start_wqthread + 4
Thread 4:
0 libsystem_kernel.dylib 0x381ddc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38241e06 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38241cc0 start_wqthread + 4
Thread 5:
0 libsystem_kernel.dylib 0x381caa84 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x381ca87c mach_msg + 36
2 AudioToolbox 0x2d26d99c AURemoteIO::IOThread::Run() + 184
3 AudioToolbox 0x2d271438 AURemoteIO::IOThread::Entry(void*) + 4
4 AudioToolbox 0x2d19f2ac CAPThread::Entry(CAPThread*) + 208
5 libsystem_pthread.dylib 0x38243c5a _pthread_body + 138
6 libsystem_pthread.dylib 0x38243bca _pthread_start + 98
7 libsystem_pthread.dylib 0x38241ccc thread_start + 4
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0xdeadbeef r1: 0x00000001 r2: 0x1b48d000 r3: 0x00000044
r4: 0x00000000 r5: 0x04e5d560 r6: 0x04e5d438 r7: 0x27d088c0
r8: 0x00000000 r9: 0x00000fff r10: 0x04e5d000 r11: 0x04e5b90f
ip: 0x3a004114 sp: 0x27d088a0 lr: 0x322023d9 pc: 0x3220193a
cpsr: 0x20000030
What can cause it?

The problem can be caused by audio, if so you can check the answer here https://stackoverflow.com/a/19283721/1278463
I solved this in a game which is not using audio. Th solution is to pause SKView when entering background:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
SKView *view = (SKView *)self.window.rootViewController.view;
if (view) {
view.paused = YES;
}
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
SKView *view = (SKView *)self.window.rootViewController.view;
if (view) {
view.paused = NO;
}
}

For me, pausing the SKView and using [[SKView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)] instead of [[SKView alloc] init] solve the issue !
[[SKView alloc] init] seems to be bugged !

It's most likely a bug within SpriteKit. Check out this thread for a solution: SpriteKit- the right way to multitask

Related

NSUserDefaults integerForKey EXC_BAD_ACCESS?

I'm using NSUserDefaults in my application. I received quite a lot crash reports with code that crashes on
[[NSUserDefaults standardUserDefaults] integerForKey:MY_KEY];
with EXC_BAD_ACCESS.
Constants are defined in separate .h header files.
static NSString *const MY_KEY = #"myKey";
static NSInteger const SOME_VALUE = 0;
Part of controller method that crashes
- (void)displayData:(NSInteger)param {
NSString *string1;
NSString *string2;
NSInteger value = [[NSUserDefaults standardUserDefaults] integerForKey: MY_KEY];
}
This is the crash report in Xcode Organizer
This is the crash log
Incident Identifier: 1DD7D3CD-DE9B-4623-AB02-06D2365728DA
CrashReporter Key: 020e241bb4242d3e055b3eef0f3ab86f54af59df
Hardware Model: iPhone6,2
Process: My App [194]
Path: /private/var/mobile/Containers/Bundle/Application/31286A32-F4D3-48E1-8B05-ECE119EA96A8/MyApp.app/My App
Identifier: com.mycompany.myapp
Version: 1.0.0 (1.0.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2016-01-16 12:55:34.34 +0200
Launch Time: 2016-01-16 12:24:31.31 +0200
OS Version: iOS 9.2 (13C75)
Report Version: 105
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000000158b6560
Triggered by Thread: 0
Filtered syslog:
None found
Global Trace Buffer (reverse chronological seconds):
1.629540 CFNetwork 0x00000001851af104 TCP Conn 0x15a473640 complete. fd: 8, err: 0
1.629540 CFNetwork 0x00000001851b0630 TCP Conn 0x15a473640 event 1. err: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x00000001841b5bd0 objc_msgSend + 16
1 CoreFoundation 0x0000000184b69118 __CFBasicHashAddValue + 328
2 CoreFoundation 0x0000000184a179d8 CFBasicHashAddValue + 288
3 CoreFoundation 0x0000000184a18c90 CFDictionaryAddValue + 248
4 CoreFoundation 0x0000000184a305a8 __CFDictionaryApplyFunction_block_invoke + 24
5 CoreFoundation 0x0000000184a189bc CFBasicHashApply + 128
6 CoreFoundation 0x0000000184a21d3c CFDictionaryApplyFunction + 200
7 CoreFoundation 0x0000000184abd8a8 -[CFPrefsPlistSource mergeIntoDictionary:] + 304
8 CoreFoundation 0x0000000184ae45e0 -[CFPrefsSearchListSource alreadylocked_copyDictionary] + 828
9 CoreFoundation 0x0000000184ae33fc -[CFPrefsSearchListSource alreadylocked_copyValueForKey:] + 72
10 CoreFoundation 0x0000000184b74ee4 ___CFPreferencesCopyAppValueWithContainer_block_invoke + 68
11 CoreFoundation 0x0000000184ae25b8 +[CFPrefsSearchListSource withSearchListForIdentifier:container:perform:] + 572
12 CoreFoundation 0x0000000184b74e5c _CFPreferencesCopyAppValueWithContainer + 188
13 CoreFoundation 0x0000000184b75130 _CFPreferencesGetAppIntegerValueWithContainer + 28
14 My App 0x000000010006f520 -[MyController displayData:] (MyController.m:998)
15 Foundation 0x0000000185425844 -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 988
16 Foundation 0x00000001854296a0 -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 144
17 My App 0x000000010006cd68 -[MyController StateDidChange:] (MyController.m:307)
18 Foundation 0x00000001854f7e20 __NSThreadPerformPerform + 340
19 CoreFoundation 0x0000000184aecefc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
20 CoreFoundation 0x0000000184aec990 __CFRunLoopDoSources0 + 540
21 CoreFoundation 0x0000000184aea690 __CFRunLoopRun + 724
22 CoreFoundation 0x0000000184a19680 CFRunLoopRunSpecific + 384
23 GraphicsServices 0x0000000185f28088 GSEventRunModal + 180
24 UIKit 0x0000000189890d90 UIApplicationMain + 204
25 My App 0x000000010006b6b4 main (main.m:16)
26 libdyld.dylib 0x00000001845ba8b8 start + 4
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x00000001846d94fc kevent_qos + 8
1 libdispatch.dylib 0x000000018459c94c _dispatch_mgr_invoke + 232
2 libdispatch.dylib 0x000000018458b7bc _dispatch_source_invoke + 0
Thread 2 name: com.apple.NSURLConnectionLoader
Thread 2:
0 libsystem_kernel.dylib 0x00000001846bd4bc mach_msg_trap + 8
1 libsystem_kernel.dylib 0x00000001846bd338 mach_msg + 72
2 CoreFoundation 0x0000000184aecac0 __CFRunLoopServiceMachPort + 196
3 CoreFoundation 0x0000000184aea7c4 __CFRunLoopRun + 1032
4 CoreFoundation 0x0000000184a19680 CFRunLoopRunSpecific + 384
5 CFNetwork 0x0000000185189434 +[NSURLConnection(Loader) _resourceLoadLoop:] + 412
6 Foundation 0x00000001854f7c40 __NSThread__start__ + 1000
7 libsystem_pthread.dylib 0x000000018479fb28 _pthread_body + 156
8 libsystem_pthread.dylib 0x000000018479fa8c _pthread_body + 0
9 libsystem_pthread.dylib 0x000000018479d028 thread_start + 4
Thread 3 name: com.apple.CFSocket.private
Thread 3:
0 libsystem_kernel.dylib 0x00000001846d8368 __select + 8
1 CoreFoundation 0x0000000184af3028 __CFSocketManager + 648
2 libsystem_pthread.dylib 0x000000018479fb28 _pthread_body + 156
3 libsystem_pthread.dylib 0x000000018479fa8c _pthread_body + 0
4 libsystem_pthread.dylib 0x000000018479d028 thread_start + 4
Thread 4 name: NetworkLoad
Thread 4:
0 libsystem_kernel.dylib 0x00000001846bd4bc mach_msg_trap + 8
1 libsystem_kernel.dylib 0x00000001846bd338 mach_msg + 72
2 CoreFoundation 0x0000000184aecac0 __CFRunLoopServiceMachPort + 196
3 CoreFoundation 0x0000000184aea7c4 __CFRunLoopRun + 1032
4 CoreFoundation 0x0000000184a19680 CFRunLoopRunSpecific + 384
5 GeoServices 0x000000018b1e9b5c _runNetworkThread + 428
6 libsystem_pthread.dylib 0x000000018479fb28 _pthread_body + 156
7 libsystem_pthread.dylib 0x000000018479fa8c _pthread_body + 0
8 libsystem_pthread.dylib 0x000000018479d028 thread_start + 4
Thread 5:
0 libsystem_kernel.dylib 0x00000001846d8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x000000018479d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x000000018479d020 start_wqthread + 4
Thread 6:
0 libsystem_kernel.dylib 0x00000001846d8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x000000018479d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x000000018479d020 start_wqthread + 4
Thread 7:
0 libsystem_kernel.dylib 0x00000001846d8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x000000018479d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x000000018479d020 start_wqthread + 4
Thread 8:
0 libsystem_kernel.dylib 0x00000001846d8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x000000018479d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x000000018479d020 start_wqthread + 4
Thread 9:
0 libsystem_kernel.dylib 0x00000001846d7f48 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x000000018479ece8 _pthread_cond_wait + 648
2 Foundation 0x0000000185462bac -[NSCondition wait] + 240
3 Foundation 0x0000000185425780 -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 792
4 Foundation 0x00000001854296a0 -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 144
5 My App 0x0000000100085714 -[AppStateManager HandleAsynchRequest:] (AppStateManager.m:328)
6 Foundation 0x00000001854f7c40 __NSThread__start__ + 1000
7 libsystem_pthread.dylib 0x000000018479fb28 _pthread_body + 156
8 libsystem_pthread.dylib 0x000000018479fa8c _pthread_body + 0
9 libsystem_pthread.dylib 0x000000018479d028 thread_start + 4
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000155616b10 x1: 0x000000018a206102 x2: 0x00000001556169c0 x3: 0x0000000155616b10
x4: 0x000000015680c2c0 x5: 0x0000000000000010 x6: 0x0000000000000067 x7: 0x0000000000000fd0
x8: 0x00000001a1223000 x9: 0x00000000158b6550 x10: 0x00000001a216a000 x11: 0x00000001a216a000
x12: 0x00000001556169d0 x13: 0x10000000158b6554 x14: 0x000000000000008c x15: 0x00000001556169dd
x16: 0x5000f8d3b4fb11e2 x17: 0x00000001556169dd x18: 0x0000000000000000 x19: 0x000000015680c240
x20: 0x00000001556169c0 x21: 0x0000000155616b10 x22: 0x0000000000000001 x23: 0x00000001a2165360
x24: 0x0000000184aee6c8 x25: 0x00000001a2165360 x26: 0x0000000000000003 x27: 0x0000000158ffa300
x28: 0x00000000a7baadb1 fp: 0x000000016fd99f50 lr: 0x0000000184b69118
sp: 0x000000016fd99f00 pc: 0x00000001841b5bd0 cpsr: 0x20000000
I'm getting this message with zombies enabled
[CFString retain]: message sent to deallocated instance 0x12f78f7e0
I replicated this bug once on my development iPhone. Also note that the application uses real-time TCP communication. When I receive some data a block is created to show the data in the UI.
Can NSUserDefaults produce a EXC_BAD_ACCESS?
It's an issue related to memory leaks. To solve the problem use Xcode static analysis to find potential memory leaks in the code. Also run Xcode instruments with Leaks configuration.

Intermittent iPad app crash using Swift

I have been seeing the following crash intermittently in my app. Following is the crash log for the crash. I am not able to figure out the cause for this crash. I would really appreciate if anyone could help me with the reason behind this crash.
CRASHLOG:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000000000defe
Triggered by Thread: 5
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x34515648 syscall_thread_switch + 8
1 libsystem_platform.dylib 0x345a2646 _OSSpinLockLockSlow$VARIANT$mp + 42
2 CFNetwork 0x25df2f7e _BrowserCancel(__CFNetServiceBrowser*) + 22
3 CoreFoundation 0x2631f804 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
4 CoreFoundation 0x2631ec16 __CFRunLoopDoSources0 + 218
5 CoreFoundation 0x2631d294 __CFRunLoopRun + 764
6 CoreFoundation 0x2626adac CFRunLoopRunSpecific + 472
7 CoreFoundation 0x2626abbe CFRunLoopRunInMode + 102
8 GraphicsServices 0x2d5dc04c GSEventRunModal + 132
9 UIKit 0x29836a2c UIApplicationMain + 1436
10 Xavier 0x000c85c4 0x6c000 + 378308
11 Xavier 0x000c8720 0x6c000 + 378656
12 libdyld.dylib 0x34463aac start + 0
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x345152c8 kevent64 + 24
1 libdispatch.dylib 0x34437ec4 _dispatch_mgr_invoke + 276
2 libdispatch.dylib 0x34437bf6 _dispatch_mgr_thread$VARIANT$mp + 34
Thread 2 name: com.apple.CFSocket.private
Thread 2:
0 libsystem_kernel.dylib 0x3452908c __select + 20
1 CoreFoundation 0x2632354e __CFSocketManager + 486
2 libsystem_pthread.dylib 0x345a7e64 _pthread_body + 136
3 libsystem_pthread.dylib 0x345a7dd6 _pthread_start + 114
4 libsystem_pthread.dylib 0x345a5b80 thread_start + 4
Thread 3 name: com.apple.NSURLConnectionLoader
Thread 3:
0 libsystem_kernel.dylib 0x34515518 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3451530c mach_msg + 36
2 CoreFoundation 0x2631edc6 __CFRunLoopServiceMachPort + 142
3 CoreFoundation 0x2631d38c __CFRunLoopRun + 1012
4 CoreFoundation 0x2626adac CFRunLoopRunSpecific + 472
5 CoreFoundation 0x2626abbe CFRunLoopRunInMode + 102
6 CFNetwork 0x25e231fa +[NSURLConnection(Loader) _resourceLoadLoop:] + 482
7 Foundation 0x270671b6 __NSThread__main__ + 1114
8 libsystem_pthread.dylib 0x345a7e64 _pthread_body + 136
9 libsystem_pthread.dylib 0x345a7dd6 _pthread_start + 114
10 libsystem_pthread.dylib 0x345a5b80 thread_start + 4
Thread 4:
0 libsystem_kernel.dylib 0x34515518 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3451530c mach_msg + 36
2 CoreFoundation 0x2631edc6 __CFRunLoopServiceMachPort + 142
3 CoreFoundation 0x2631d38c __CFRunLoopRun + 1012
4 CoreFoundation 0x2626adac CFRunLoopRunSpecific + 472
5 CoreFoundation 0x262b46c6 CFRunLoopRun + 94
6 CoreMotion 0x26b6bb7a 0x26b2d000 + 256890
7 libsystem_pthread.dylib 0x345a7e64 _pthread_body + 136
8 libsystem_pthread.dylib 0x345a7dd6 _pthread_start + 114
9 libsystem_pthread.dylib 0x345a5b80 thread_start + 4
Thread 5 name: Dispatch queue: com.apple.MCSession.callbackQueue
Thread 5 Crashed:
0 libswiftCore.dylib 0x0049b69c 0x304000 + 1668764
1 Xavier 0x000d4af8 0x6c000 + 428792
2 Xavier 0x000d5008 0x6c000 + 430088
3 MultipeerConnectivity 0x2824ba26 __58-[MCSession syncHandleNetworkEvent:pid:freeEventWhenDone:]_block_invoke617 + 114
4 libdispatch.dylib 0x34428610 _dispatch_call_block_and_release + 8
5 libdispatch.dylib 0x34432714 _dispatch_queue_drain$VARIANT$mp + 944
6 libdispatch.dylib 0x344321e4 _dispatch_queue_invoke$VARIANT$mp + 80
7 libdispatch.dylib 0x34434156 _dispatch_root_queue_drain + 310
8 libdispatch.dylib 0x3443527a _dispatch_worker_thread3 + 102
9 libsystem_pthread.dylib 0x345a5e22 _pthread_wqthread + 666
10 libsystem_pthread.dylib 0x345a5b74 start_wqthread + 4
Thread 6:
0 libsystem_kernel.dylib 0x345299cc __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x345a5e9c _pthread_wqthread + 788
2 libsystem_pthread.dylib 0x345a5b74 start_wqthread + 4
Thread 7:
0 libsystem_kernel.dylib 0x345299cc __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x345a5e9c _pthread_wqthread + 788
2 libsystem_pthread.dylib 0x345a5b74 start_wqthread + 4
Thread 8:
0 libsystem_kernel.dylib 0x345299cc __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x345a5e9c _pthread_wqthread + 788
2 libsystem_pthread.dylib 0x345a5b74 start_wqthread + 4
Thread 9:
0 libsystem_kernel.dylib 0x345299cc __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x345a5e9c _pthread_wqthread + 788
2 libsystem_pthread.dylib 0x345a5b74 start_wqthread + 4
Thread 10 name: com.apple.gamekitservices.gcksession.recvproc
Thread 10:
0 libsystem_kernel.dylib 0x3452908c __select + 20
1 MultipeerConnectivity 0x2825f8cc gckSessionRecvProc + 5252
2 libsystem_pthread.dylib 0x345a7e64 _pthread_body + 136
3 libsystem_pthread.dylib 0x345a7dd6 _pthread_start + 114
4 libsystem_pthread.dylib 0x345a5b80 thread_start + 4
Thread 11 name: com.apple.gamekitservices.gcksession.sendproc
Thread 11:
0 libsystem_kernel.dylib 0x3452908c __select + 20
1 MultipeerConnectivity 0x2825fe68 gckSessionSendProc + 268
2 libsystem_pthread.dylib 0x345a7e64 _pthread_body + 136
3 libsystem_pthread.dylib 0x345a7dd6 _pthread_start + 114
4 libsystem_pthread.dylib 0x345a5b80 thread_start + 4
Thread 12 name: com.apple.gamekitservices.eventcallback.eventcbproc
Thread 12:
0 libsystem_kernel.dylib 0x34528b38 __psynch_cvwait + 24
1 libsystem_pthread.dylib 0x345a73dc _pthread_cond_wait + 516
2 libsystem_pthread.dylib 0x345a82ac pthread_cond_wait + 36
3 MultipeerConnectivity 0x28279a4c EventCBProc + 76
4 libsystem_pthread.dylib 0x345a7e64 _pthread_body + 136
5 libsystem_pthread.dylib 0x345a7dd6 _pthread_start + 114
6 libsystem_pthread.dylib 0x345a5b80 thread_start + 4
Thread 13:
0 libsystem_kernel.dylib 0x34528b38 __psynch_cvwait + 24
1 libsystem_pthread.dylib 0x345a7416 _pthread_cond_wait + 574
2 libsystem_pthread.dylib 0x345a71d0 pthread_cond_timedwait_relative_np + 12
3 MultipeerConnectivity 0x2825de5c gckSessionRecvUDPPacketWithTimeout + 252
4 ICE 0x2d297234 ICERecvUDPPacketWithTimeout + 340
5 ICE 0x2d29eed2 RecvAndProcess + 310
6 ICE 0x2d2a2d1e ConnectivityCheckProc + 894
7 libsystem_pthread.dylib 0x345a7e64 _pthread_body + 136
8 libsystem_pthread.dylib 0x345a7dd6 _pthread_start + 114
9 libsystem_pthread.dylib 0x345a5b80 thread_start + 4
Thread 5 crashed with ARM Thread State (32-bit):
r0: 0x00000000 r1: 0x29f6be18 r2: 0x34e7b7e4 r3: 0x00000000
r4: 0x17de21f0 r5: 0x2d34620a r6: 0x17de60d0 r7: 0x00852bc8
r8: 0x17de60d0 r9: 0x18a6a4c0 r10: 0x36c40660 r11: 0x00000000
ip: 0x33ee2531 sp: 0x00852bc4 lr: 0x33ee25c3 pc: 0x0049b69c
cpsr: 0x60000030
My breakpoint hits this line before it crashes:
let rootVC: UINavigationController = UIApplication.sharedApplication().keyWindow.rootViewController as UINavigationController
Following is the whole method that contains this line:
func session(session: MCSession!, didReceiveData data: NSData!, fromPeer peerID: MCPeerID!) {
//Check to see what kind of data is received
var dataReceived:AnyObject = NSKeyedUnarchiver.unarchiveObjectWithData(data)!;
if let newData = dataReceived as? String {
let rootVC: UINavigationController = UIApplication.sharedApplication().keyWindow.rootViewController as UINavigationController;
let topVC = rootVC.topViewController;
if let block = self.commandResolver[newData] {
block(topVC);
return;
} else {
println("Command resolver returns nil block");
}
} else if let newData = dataReceived as? NSDictionary {
let rootVC: UINavigationController = UIApplication.sharedApplication().keyWindow.rootViewController as UINavigationController;
let topVC = rootVC.topViewController as ViewController;
topVC.connected(true, withGroupName: newData["GroupName"] as String!);
} else {
println("Data is not a String");
}
}
My window.rootViewController is UINavigationController so it should not be nil if that is the problem. Can it be though?
I would really appreciate your help guys.
It's crashing in a background thread inside this block:
3 MultipeerConnectivity 0x2824ba26 __58-[MCSession syncHandleNetworkEvent:pid:freeEventWhenDone:]_block_invoke617 + 114
UIKit is generally not thread-safe and is "Main Thread only", so the fact that calling UIApplication.sharedApplication().keyWindow.rootViewController from a background thread crashes is not surprising. You probably want to dispatch this whole block back to the main thread.

iOS app crash only if run from instrument (Automation)

My app do not crash on device. No leaks no memory warning. I was living happily. But recently I was doing some UI testing with Instrument(Automation). Boom Boom. App crashes after using it like 8 min. Looping around like 30 times. And it keep crashing but after different durations but all at same step. Again no leaks no memory warning. Again it do not crash on device(without instrument) doesn't matter how long use my app.
+ Every times it crashes after I pop a specific ViewController. And that view controller is loaded with stuffs (image view, playing and recording audio, take photo from album and camera)
Here is the device log. Any kind of help is highly appreciated.
Incident Identifier:
CrashReporter Key:
Hardware Model: iPhone5,2
Process: My App [15196]
Path:
Identifier: My App
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-08-16 12:48:10.814 +0200
OS Version: iOS 6.1.3 (10B329)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x1208b319
Crashed Thread: 6
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x39be3e30 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x39be3fd0 mach_msg + 48
2 CoreFoundation 0x319da2b6 __CFRunLoopServiceMachPort + 126
3 CoreFoundation 0x319d8fd6 __CFRunLoopRun + 814
4 CoreFoundation 0x3194c238 CFRunLoopRunSpecific + 352
5 CoreFoundation 0x3194c0c4 CFRunLoopRunInMode + 100
6 GraphicsServices 0x3552b336 GSEventRunModal + 70
7 UIKit 0x338682b4 UIApplicationMain + 1116
8 MyApp 0x0000531e 0x3000 + 8990
9 MyApp 0x000052d4 0x3000 + 8916
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x39be45d0 kevent64 + 24
1 libdispatch.dylib 0x39b1fd22 _dispatch_mgr_invoke + 806
2 libdispatch.dylib 0x39b1b374 _dispatch_mgr_thread + 32
Thread 2 name: WebThread
Thread 2:
0 libsystem_kernel.dylib 0x39be3e30 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x39be3fd0 mach_msg + 48
2 CoreFoundation 0x319da2b6 __CFRunLoopServiceMachPort + 126
3 CoreFoundation 0x319d902c __CFRunLoopRun + 900
4 CoreFoundation 0x3194c238 CFRunLoopRunSpecific + 352
5 CoreFoundation 0x3194c0c4 CFRunLoopRunInMode + 100
6 WebCore 0x37954390 RunWebThread(void*) + 440
7 libsystem_c.dylib 0x39b4d0de _pthread_start + 306
8 libsystem_c.dylib 0x39b4cfa4 thread_start + 4
Thread 3:
0 libsystem_kernel.dylib 0x39be3e30 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x39be3fd0 mach_msg + 48
2 CoreFoundation 0x319da2b6 __CFRunLoopServiceMachPort + 126
3 CoreFoundation 0x319d902c __CFRunLoopRun + 900
4 CoreFoundation 0x3194c238 CFRunLoopRunSpecific + 352
5 CoreFoundation 0x3194c0c4 CFRunLoopRunInMode + 100
6 Foundation 0x322705be -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
7 MyApp 0x00020b0a 0x3000 + 121610
8 Foundation 0x3231d22c __NSThread__main__ + 968
9 libsystem_c.dylib 0x39b4d0de _pthread_start + 306
10 libsystem_c.dylib 0x39b4cfa4 thread_start + 4
Thread 4 name: com.apple.NSURLConnectionLoader
Thread 4:
0 libsystem_kernel.dylib 0x39be3e30 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x39be3fd0 mach_msg + 48
2 CoreFoundation 0x319da2b6 __CFRunLoopServiceMachPort + 126
3 CoreFoundation 0x319d902c __CFRunLoopRun + 900
4 CoreFoundation 0x3194c238 CFRunLoopRunSpecific + 352
5 CoreFoundation 0x3194c0c4 CFRunLoopRunInMode + 100
6 Foundation 0x32299888 +[NSURLConnection(Loader) _resourceLoadLoop:] + 304
7 Foundation 0x3231d22c __NSThread__main__ + 968
8 libsystem_c.dylib 0x39b4d0de _pthread_start + 306
9 libsystem_c.dylib 0x39b4cfa4 thread_start + 4
Thread 5 name: com.apple.CFSocket.private
Thread 5:
0 libsystem_kernel.dylib 0x39bf4594 __select + 20
1 CoreFoundation 0x319de474 __CFSocketManager + 676
2 libsystem_c.dylib 0x39b4d0de _pthread_start + 306
3 libsystem_c.dylib 0x39b4cfa4 thread_start + 4
Thread 6 Crashed:
0 Foundation 0x3231d692 __NSFinalizeThreadData + 122
1 CoreFoundation 0x319d6212 __CFTSDFinalize + 62
2 libsystem_c.dylib 0x39b3feb8 _pthread_tsd_cleanup + 172
3 libsystem_c.dylib 0x39b3fb8e _pthread_exit + 114
4 libsystem_c.dylib 0x39b42ade _pthread_workq_return + 22
5 libsystem_c.dylib 0x39b427f2 _pthread_wqthread + 362
6 libsystem_c.dylib 0x39b42680 start_wqthread + 4
Thread 7:
0 libsystem_kernel.dylib 0x39bf4d98 __workq_kernreturn + 8
1 libsystem_c.dylib 0x39b42ad6 _pthread_workq_return + 14
2 libsystem_c.dylib 0x39b427f2 _pthread_wqthread + 362
3 libsystem_c.dylib 0x39b42680 start_wqthread + 4
Thread 8:
0 libsystem_kernel.dylib 0x39bf4d98 __workq_kernreturn + 8
1 libsystem_c.dylib 0x39b42ad6 _pthread_workq_return + 14
2 libsystem_c.dylib 0x39b427f2 _pthread_wqthread + 362
3 libsystem_c.dylib 0x39b42680 start_wqthread + 4
Thread 9 name: AURemoteIO::IOThread
Thread 9:
0 libsystem_kernel.dylib 0x39be3e30 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x39be3fd0 mach_msg + 48
2 AudioToolbox 0x314cdc80 AURemoteIO::IOThread::Run() + 104
3 AudioToolbox 0x314d000c AURemoteIO::IOThread::Entry(void*) + 4
4 AudioToolbox 0x3140d9f2 CAPThread::Entry(CAPThread*) + 294
5 libsystem_c.dylib 0x39b4d0de _pthread_start + 306
6 libsystem_c.dylib 0x39b4cfa4 thread_start + 4
Thread 6 crashed with ARM Thread State (32-bit):
r0: 0x0010f522 r1: 0x39700941 r2: 0x39e57e88 r3: 0x1f8dc028
r4: 0x1208b2fd r5: 0x0000001c r6: 0x00000000 r7: 0x04af9f18
r8: 0x1f8dc028 r9: 0x007f8014 r10: 0x00000004 r11: 0x00000037
ip: 0x39d4db30 sp: 0x04af9d50 lr: 0x31946eb7 pc: 0x3231d692
cpsr: 0x20000030
EXC_BAD_ACCESS generally means that you are sending a objective c message to an invalid memory address. This happens because an object that you are using has been deallocated.
Use NSZombieEnabled to get more information.
Start commenting out stuff. It's a memory issue, find the offending line of code.

Cocos2D 2 OSX EXC_BAD_ACCESS (SIGSEGV)

I'm updating a Game I have for the Mac and the update works fine while running through XCode.
I try to Distribute through Developer ID-signed Application so I can have a friend test it and when I run the app and also give them the app it crashes just after the Main Menu. Am I exporting it wrong? Why would it run fine through XCode and then I try to export it and it crashes every time?
Here is my error log:
Crashed Thread: 6 CVDisplayLink
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000121028021
VM Regions Near 0x121028021:
CG shared images 000000011f294000-000000011f29c000 [ 32K] r--/r-- SM=SHM
-->
CG shared images 00000001c0001000-00000001c0009000 [ 32K] rw-/rw- SM=SHM
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff91ef6686 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff91ef5c42 mach_msg + 70
2 com.apple.CoreFoundation 0x00007fff8bf01803 __CFRunLoopServiceMachPort + 195
3 com.apple.CoreFoundation 0x00007fff8bf06ee6 __CFRunLoopRun + 1078
4 com.apple.CoreFoundation 0x00007fff8bf066b2 CFRunLoopRunSpecific + 290
5 com.apple.HIToolbox 0x00007fff943620a4 RunCurrentEventLoopInMode + 209
6 com.apple.HIToolbox 0x00007fff94361e42 ReceiveNextEventCommon + 356
7 com.apple.HIToolbox 0x00007fff94361cd3 BlockUntilNextEventMatchingListInMode + 62
8 com.apple.AppKit 0x00007fff961c8613 _DPSNextEvent + 685
9 com.apple.AppKit 0x00007fff961c7ed2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
10 com.apple.AppKit 0x00007fff961bf283 -[NSApplication run] + 517
11 com.apple.AppKit 0x00007fff96163cb6 NSApplicationMain + 869
12 libdyld.dylib 0x00007fff916837e1 start + 1
Thread 1:
0 libsystem_kernel.dylib 0x00007fff91ef86d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff8ce15eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff8ce15cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff8ce00171 start_wqthread + 13
Thread 2:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff91ef8d16 kevent + 10
1 libdispatch.dylib 0x00007fff91fbfdea _dispatch_mgr_invoke + 883
2 libdispatch.dylib 0x00007fff91fbf9ee _dispatch_mgr_thread + 54
Thread 3:
0 libsystem_kernel.dylib 0x00007fff91ef86d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff8ce15eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff8ce15cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff8ce00171 start_wqthread + 13
Thread 4:
0 libsystem_kernel.dylib 0x00007fff91ef86d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff8ce15eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff8ce15cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff8ce00171 start_wqthread + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff91ef86d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff8ce15eec _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff8ce15cb3 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff8ce00171 start_wqthread + 13
Thread 6 Crashed:: CVDisplayLink
0 com.lasthaven.wordshufflemac 0x000000010bacc52a -[GameScene scrambleWord:] + 158 (GameScene.m:322)
1 com.lasthaven.wordshufflemac 0x000000010baced36 -[GameScene setupNewWord] + 373 (GameScene.m:878)
2 com.lasthaven.wordshufflemac 0x000000010bacb6c1 -[GameScene initializeGame] + 941 (GameScene.m:112)
3 com.lasthaven.wordshufflemac 0x000000010bacb2fc -[GameScene init] + 428 (GameScene.m:56)
4 com.lasthaven.wordshufflemac 0x000000010baf30c1 +[CCNode node] + 33
5 com.lasthaven.wordshufflemac 0x000000010bacb11b +[GameScene scene] + 62 (GameScene.m:32)
6 com.lasthaven.wordshufflemac 0x000000010bac9f90 -[MenuScene playGame:] + 363 (MenuScene.m:301)
7 com.lasthaven.wordshufflemac 0x000000010baee7e3 -[CCMenu ccMouseUp:] + 112
8 com.lasthaven.wordshufflemac 0x000000010bb177fb -[CCEventDispatcher mouseUp:] + 101
9 com.apple.Foundation 0x00007fff97fa5220 -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 212
10 com.apple.Foundation 0x00007fff97fdf8b9 -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:] + 122
11 com.lasthaven.wordshufflemac 0x000000010bb17f25 -[CCEventDispatcher dispatchEvent:] + 140
12 com.apple.Foundation 0x00007fff97fab677 __NSThreadPerformPerform + 225
13 com.apple.CoreFoundation 0x00007fff8bee4101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 com.apple.CoreFoundation 0x00007fff8bee3a25 __CFRunLoopDoSources0 + 245
15 com.apple.CoreFoundation 0x00007fff8bf06dc5 __CFRunLoopRun + 789
16 com.apple.CoreFoundation 0x00007fff8bf066b2 CFRunLoopRunSpecific + 290
17 com.apple.Foundation 0x00007fff97fb389e -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 268
18 com.lasthaven.wordshufflemac 0x000000010bb16888 -[CCDirectorDisplayLink getFrameForTime:] + 162
19 com.apple.CoreVideo 0x00007fff8c0c603d CVDisplayLink::performIO(CVTimeStamp*) + 203
20 com.apple.CoreVideo 0x00007fff8c0c52a4 CVDisplayLink::runIOThread() + 632
21 com.apple.CoreVideo 0x00007fff8c0c5013 startIOThread(void*) + 148
22 libsystem_c.dylib 0x00007fff8ce13742 _pthread_start + 327
23 libsystem_c.dylib 0x00007fff8ce00181 thread_start + 13
scratch that.
after staring at this line for hours:
0 com.lasthaven.wordshufflemac 0x000000010bacc52a -[GameScene scrambleWord:] + 158 (GameScene.m:322)
I realized that the code consisted of a for loop and I couldn't figure out what was wrong with it! So in the end I forgot to initialize the int i in beginning of the for loop.
for(int i = 0; i < [word length]; i++ {
}
So for something so simple that caused a crash outside of XCode but not within it drove me nuts!
Thanks for reading!

Cocoa App crash calling a 3rd party API

My Cocoa Objective-C app (in XCode) occasionally crashes in the part where it calls a 3rd party API. I believe that it's a memory leak or something. I attach the part where my program will, the 3rd party API and the crash log.
Please help to give me pointers on how I can solve this. Thanks a lot!
My code:
.
.
.
uint8_t InfoProg[4];//10
uint8_t nInfoProg = 4;//10
uint8_t ret;
NSString *result;
NSLog(#"***Calling GetConnectedProgramers***");
ret = GetConnectedProgrammers(InfoProg, nInfoProg); // The part where it crashes sometimes
.
.
.
3rd party API function:
/**
GET INFO ON CONNECTED USB PROGRAMMERS
reports back the number of connected USB programmer devices on the host
#param InfoProg
points to the memory that will be filled with the info on the connected
USB programmers;
it is the responsibility of the application to allocate this memory
and to size it sufficiently. This should be an buffer with at least 8 bytes.
InfoProg[x] = 0; no USB programmer allocated to that number
InfoProg[x] = 1; USB programmer allocated to that number = USB programmer available
#param nInfoProg
is the number of requested data structures
#return
is the number of programmers connected
*/
uint8_t GetConnectedProgrammers (uint8_t *InfoProg, uint8_t nInfoProg);
Crash Report:
Process: FCT_MACOS [575]
Path: /Virgo_FG2_EVT/FCT_MACOS3p55c.app/Contents/MacOS/FCT_MACOS
Identifier: com.TopTest.FCTMACOS
Version: 3.55c (3.55c)
Code Type: X86 (Native)
Parent Process: launchd [132]
Date/Time: 2012-08-03 10:34:35.151 +0800
OS Version: Mac OS X 10.7.3 (11D2001)
Report Version: 9
Interval Since Last Report: 16921 sec
Crashes Since Last Report: 3
Per-App Interval Since Last Report: 5164 sec
Per-App Crashes Since Last Report: 3
Anonymous UUID: 22314E10-99B9-4989-A2E8-53631295027B
Crashed Thread: 4
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000000005a5
VM Regions Near 0x5a5:
--> __PAGEZERO 0000000000000000-0000000000001000 [ 4K] ---/--- SM=NUL /Virgo_FG2_EVT/FCT_MACOS3p55c.app/Contents/MacOS/FCT_MACOS
VM_ALLOCATE 0000000000001000-0000000000013000 [ 72K] ---/--- SM=NUL
Application Specific Information:
objc_msgSend() selector name: isEqual:
objc[575]: garbage collection is OFF
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x964edc22 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x964ed1f6 mach_msg + 70
2 com.apple.CoreFoundation 0x9677ec7a __CFRunLoopServiceMachPort + 170
3 com.apple.CoreFoundation 0x96787da4 __CFRunLoopRun + 1428
4 com.apple.CoreFoundation 0x9678747c CFRunLoopRunSpecific + 332
5 com.apple.CoreFoundation 0x96787328 CFRunLoopRunInMode + 120
6 com.apple.HIToolbox 0x9973417f RunCurrentEventLoopInMode + 318
7 com.apple.HIToolbox 0x9973b4e7 ReceiveNextEventCommon + 381
8 com.apple.HIToolbox 0x9973b356 BlockUntilNextEventMatchingListInMode + 88
9 com.apple.AppKit 0x957dfa9c _DPSNextEvent + 678
10 com.apple.AppKit 0x957df306 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 113
11 com.apple.AppKit 0x957db675 -[NSApplication run] + 911
12 com.apple.AppKit 0x95a6f261 NSApplicationMain + 1054
13 com.TopTest.FCTMACOS 0x00014055 start + 53
Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x964f090a kevent + 10
1 libdispatch.dylib 0x97c1dc58 _dispatch_mgr_invoke + 969
2 libdispatch.dylib 0x97c1c6a7 _dispatch_mgr_thread + 53
Thread 2:
0 libsystem_kernel.dylib 0x964f0ef2 __sem_wait + 10
1 com.ni.framework.nipalu 0x001ebd0b tTimerTimeWasterSleep::sleep(u64, tTimerTimeUnit, long*) const + 3019
2 com.ni.framework.NI4882 0x06cad33c WaitSRQ + 99996
3 com.ni.framework.nipalu 0x001edc78 tThreadUtility::getCurrentThreadId() + 104
4 libsystem_c.dylib 0x918aeed9 _pthread_start + 335
5 libsystem_c.dylib 0x918b26de thread_start + 34
Thread 3:
0 libsystem_kernel.dylib 0x964edc22 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x964ed1f6 mach_msg + 70
2 com.apple.framework.IOKit 0x982f92df io_connect_method + 465
3 com.apple.framework.IOKit 0x982a9f21 IOConnectCallMethod + 559
4 com.apple.framework.IOKit 0x982aa21b IOConnectCallStructMethod + 84
5 com.ni.framework.nipalu 0x001f11f1 tThreadUtility::yield(iThreadController*, long*) + 12993
6 com.ni.framework.nipalu 0x001ec4b3 tTimerTimeWasterSleep::sleep(u64, tTimerTimeUnit, long*) const + 4979
7 com.ni.framework.NI4882 0x06c9940a WaitSRQ + 18282
8 com.ni.framework.nipalu 0x001edc78 tThreadUtility::getCurrentThreadId() + 104
9 libsystem_c.dylib 0x918aeed9 _pthread_start + 335
10 libsystem_c.dylib 0x918b26de thread_start + 34
Thread 4 Crashed:
0 libobjc.A.dylib 0x915bcd47 objc_msgSend + 23
1 com.apple.CoreFoundation 0x9675b57a CFEqual + 154
2 com.apple.framework.IOKit 0x982cbc80 IOHIDDeviceUnscheduleFromRunLoop + 29
3 com.TopTest.FCTMACOS 0x0008dee2 closeAll + 66
4 com.apple.CoreFoundation 0x967ea298 -[NSObject performSelector:withObject:withObject:] + 72
5 com.TopTest.FCTMACOS 0x000213ff -[TestViewController threadRunTest:] + 2593
6 com.apple.Foundation 0x97ddbe59 -[NSThread main] + 45
7 com.apple.Foundation 0x97ddbe09 __NSThread__main__ + 1582
8 libsystem_c.dylib 0x918aeed9 _pthread_start + 335
9 libsystem_c.dylib 0x918b26de thread_start + 34
Thread 5:
0 libsystem_kernel.dylib 0x964f002e __workq_kernreturn + 10
1 libsystem_c.dylib 0x918b0ccf _pthread_wqthread + 773
2 libsystem_c.dylib 0x918b26fe start_wqthread + 30
Thread 6:
0 libsystem_kernel.dylib 0x964f002e __workq_kernreturn + 10
1 libsystem_c.dylib 0x918b0ccf _pthread_wqthread + 773
2 libsystem_c.dylib 0x918b26fe start_wqthread + 30
Thread 7:
0 libsystem_kernel.dylib 0x964f002e __workq_kernreturn + 10
1 libsystem_c.dylib 0x918b0ccf _pthread_wqthread + 773
2 libsystem_c.dylib 0x918b26fe start_wqthread + 30
Thread 8:
0 libsystem_kernel.dylib 0x964f002e __workq_kernreturn + 10
1 libsystem_c.dylib 0x918b0ccf _pthread_wqthread + 773
2 libsystem_c.dylib 0x918b26fe start_wqthread + 30
Thread 9:
0 libsystem_kernel.dylib 0x964f002e __workq_kernreturn + 10
1 libsystem_c.dylib 0x918b0ccf _pthread_wqthread + 773
2 libsystem_c.dylib 0x918b26fe start_wqthread + 30
Thread 10:
0 libsystem_kernel.dylib 0x964efbb2 __semwait_signal + 10
1 libsystem_c.dylib 0x918637b9 nanosleep$UNIX2003 + 187
2 com.apple.Foundation 0x97e1c05f +[NSThread sleepForTimeInterval:] + 170
3 com.TopTest.FCTMACOS 0x0006cbd7 -[RS232 threadB139RS232Read:] + 223
4 com.apple.Foundation 0x97ddbe59 -[NSThread main] + 45
5 com.apple.Foundation 0x97ddbe09 __NSThread__main__ + 1582
6 libsystem_c.dylib 0x918aeed9 _pthread_start + 335
7 libsystem_c.dylib 0x918b26de thread_start + 34
Thread 4 crashed with X86 Thread State (32-bit):
eax: 0x78690d00 ebx: 0xac7d8724 ecx: 0x96128a48 edx: 0x00000585
edi: 0x7868cc80 esi: 0x78615800 ebp: 0xb0102c18 esp: 0xb0102bf8
ss: 0x00000023 efl: 0x00010206 eip: 0x915bcd47 cs: 0x0000001b
ds: 0x00000023 es: 0x00000023 fs: 0x00000023 gs: 0x0000000f
cr2: 0x000005a5
Logical CPU: 2
...
From the docs;
#param InfoProg
This should be an buffer with at least 8 bytes.
but
uint8_t InfoProg[4];
only consists of 4 uint8_t (bytes). Try increasing your buffer.