Search code examples
cocoastrlen

Strange Cocoa Crash on strlen in NSApplicationMain()


I Closed out of my xcode project a few days ago and when I came back, it keeps crashing! I haven't changed any of the code so I have no idea what happened. I get an EXC_BAD_ACCESS (code=1, address=0x0) on strlen inside the NSApplicationMain() method and looking at the error stack, it looks like my application hasn't even launched!

Heres the error stack

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_c.dylib               0x000000010847a650 strlen + 16
1   libsystem_c.dylib               0x00000001084c8067 strdup + 21
2   com.apple.Foundation            0x0000000104d018fb _compatDecodeValueOfObjCType + 763
3   com.apple.Foundation            0x0000000104c04da6 newDecodedValue + 1162
4   com.apple.Foundation            0x0000000104c22a09 _decodeObjectBinary + 2741
5   com.apple.Foundation            0x0000000104c21db4 _decodeObject + 226
6   com.apple.AppKit                0x000000010575991b __copyCarbonDictionariesFromRecords_block_invoke_0 + 372
7   com.apple.AppKit                0x00000001057caa35 _NSMapAndFilter + 233
8   com.apple.AppKit                0x0000000105807be2 copyCarbonDictionariesFromRecords + 30
9   com.apple.AppKit                0x000000010580799d +[NSPersistentUIManager(NSCarbonMethods) copyPersistentCarbonWindowDictionariesForBundleID:] + 144
10  com.apple.HIToolbox             0x000000010b009821 _HIPersistentUICopyPersistentCarbonWindowDictionariesForBundleID + 73
11  com.apple.HIToolbox             0x000000010b0097c7 GetPersistenceDictionariesAtLaunch() + 52
12  com.apple.HIToolbox             0x000000010b00978c WindowStateInitFirstEventTime() + 9
13  com.apple.HIToolbox             0x000000010b00915c _FirstEventTime + 50
14  com.apple.HIToolbox             0x000000010b008ffc RunCurrentEventLoopInMode + 41
15  com.apple.HIToolbox             0x000000010b008d84 ReceiveNextEventCommon + 166
16  com.apple.HIToolbox             0x000000010b008cd3 BlockUntilNextEventMatchingListInMode + 62
17  com.apple.AppKit                0x0000000105806613 _DPSNextEvent + 685
18  com.apple.AppKit                0x0000000105805ed2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
19  com.apple.AppKit                0x00000001057fd283 -[NSApplication run] + 517
20  com.apple.AppKit                0x00000001057a1cb6 NSApplicationMain + 869
21  com.littleendiangamestudios.Alone   0x0000000104b54592 main + 34 (main.m:13)
22  com.littleendiangamestudios.Alone   0x0000000104b54564 start + 52

Thread 1:
0   libsystem_kernel.dylib          0x00000001085fa6d6 __workq_kernreturn + 10
1   libsystem_c.dylib               0x000000010848eeec _pthread_workq_return + 25
2   libsystem_c.dylib               0x000000010848ecb3 _pthread_wqthread + 412
3   libsystem_c.dylib               0x0000000108479171 start_wqthread + 13

Thread 2:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib          0x00000001085fad16 kevent + 10
1   libdispatch.dylib               0x00000001083f2dea _dispatch_mgr_invoke + 883
2   libdispatch.dylib               0x00000001083f29ee _dispatch_mgr_thread + 54

Thread 3:
0   libsystem_kernel.dylib          0x00000001085fa6d6 __workq_kernreturn + 10
1   libsystem_c.dylib               0x000000010848eeec _pthread_workq_return + 25
2   libsystem_c.dylib               0x000000010848ecb3 _pthread_wqthread + 412
3   libsystem_c.dylib               0x0000000108479171 start_wqthread + 13

Thread 4:
0   libsystem_kernel.dylib          0x00000001085fa6d6 __workq_kernreturn + 10
1   libsystem_c.dylib               0x000000010848eeec _pthread_workq_return + 25
2   libsystem_c.dylib               0x000000010848ecb3 _pthread_wqthread + 412
3   libsystem_c.dylib               0x0000000108479171 start_wqthread + 13

Thread 5:
0   libsystem_kernel.dylib          0x00000001085fa6d6 __workq_kernreturn + 10
1   libsystem_c.dylib               0x000000010848eeec _pthread_workq_return + 25
2   libsystem_c.dylib               0x000000010848ecb3 _pthread_wqthread + 412
3   libsystem_c.dylib               0x0000000108479171 start_wqthread + 13

Solution

  • You appear to have got your app's persistant state corrupted somehow. If you go into your ~/Library/Saved Application State/ directory and delete the one for your application it should fix it.