App Crash on Multi-tasking re-entry (Swift) - ios

Been getting a strange error recently and hope to find a solution here. On double-clicking home and immediately re-entering the app a crash occurs. I've been looking around for a solution in other SO posts but there doesn't seem to be any that come close to this strangeness. The project uses several swift/objc open source libraries and if it is helpful I will post them here as well. I've done everything from cleaning out the AppDelegate, DerivedData/Caches, Pods, the main controllers on re-entry(home, login, auth), and no dice :(
The system logs at the time of crash from a physical device are as follows.
May 22 18:53:47 iPhone-6 SpringBoard[63] <Warning>: BSXPCMessage received error for message: Connection interrupted
May 22 18:53:47 iPhone-6 SpringBoard[63] <Warning>: HW kbd: Failed to set (null) as keyboard focus
May 22 18:53:47 iPhone-6 SpringBoard[63] <Warning>: UNNotificationRegistrarConnectionListener connection invalidated
May 22 18:53:47 iPhone-6 com.apple.debugserver-#(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[3269] <Warning>: 1 +0.000000 sec [0cc5/1b0b]: error: ::read ( -1, 0x16e246a38, 1024 ) => -1 err = Bad file descriptor (0x00000009)
May 22 18:53:47 iPhone-6 com.apple.debugserver-#(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[3269] <Warning>: Exiting.
May 22 18:53:47 iPhone-6 gputoolsd[3265] <Notice>: schedule invalidation <DYTransport 0x13d504ba0, error: explicit invalidation (6)>
May 22 18:53:47 iPhone-6 gputoolsd[3265] <Notice>: schedule invalidation <DYTransport 0x13d50f850, error: lost transport connection (31)>
May 22 18:53:47 iPhone-6 gputoolsd[3265] <Notice>: terminating daemon 0x13d50f510
May 22 18:53:47 iPhone-6 SpringBoard[63] <Warning>: Application 'UIKitApplication:com.argentapp.ios[0x552c]' exited voluntarily.
May 22 18:53:47 iPhone-6 UserEventAgent[26] <Warning>: 6754616024137: id=com.argentapp.ios pid=3270, state=0
Edit: Back Trace from breakpoint in applicationWillTerminate below. Also the wording of crash may be incorrect as the logs say that the app exited voluntarily upon re-entry and no lldb errors are thrown.
applicationWillResignActive
<UIApplication: 0x14782c3c0>
<NSUserDefaults: 0x14782ee50>
applicationWillTerminate
(lldb) bt
* thread #1: tid = 0x15fd47, 0x00000001000a86b0 Argent`AppDelegate.applicationWillTerminate(application=<unavailable>, self=<unavailable>) -> () + 188 at AppDelegate.swift:254, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x00000001000a86b0 Argent`AppDelegate.applicationWillTerminate(application=<unavailable>, self=<unavailable>) -> () + 188 at AppDelegate.swift:254
frame #1: 0x00000001000a878c Argent`#objc AppDelegate.applicationWillTerminate(UIApplication) -> () + 68 at AppDelegate.swift:0
frame #2: 0x00000001877ed240 UIKit`-[UIApplication _terminateWithStatus:] + 280
frame #3: 0x0000000187a0bff8 UIKit`__102-[UIApplication _handleApplicationDeactivationWithScene:shouldForceExit:transitionContext:completion:]_block_invoke2017 + 796
frame #4: 0x0000000187a0f0c8 UIKit`_runAfterCACommitDeferredBlocks + 292
frame #5: 0x0000000187a1ca80 UIKit`_cleanUpAfterCAFlushAndRunDeferredBlocks + 92
frame #6: 0x000000018774e5a4 UIKit`_afterCACommitHandler + 96
frame #7: 0x00000001825b4728 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
frame #8: 0x00000001825b24cc CoreFoundation`__CFRunLoopDoObservers + 372
frame #9: 0x00000001825b28fc CoreFoundation`__CFRunLoopRun + 928
frame #10: 0x00000001824dcc50 CoreFoundation`CFRunLoopRunSpecific + 384
frame #11: 0x0000000183dc4088 GraphicsServices`GSEventRunModal + 180
frame #12: 0x00000001877c6088 UIKit`UIApplicationMain + 204
frame #13: 0x00000001000a8f1c Argent`main + 144 at AppDelegate.swift:41
frame #14: 0x000000018207a8b8 libdyld.dylib`start + 4
Every other system behavior works as expected and the app functions without a hitch (pressing home and re-opening, lock screen and re-open, opening another app and re-opening, 3d touch navigation etc.). Hope this is descriptive enough, I will try to elaborate more if it is unclear.
XCode Version 7.3
iOS Version 9.3
Swift 2.2

Related

com.apple.gamed is crashing when deleting a game [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an iOS app that consistently crashes when you try to delete a GKTurnBasedMatch using
[match removeWithCompletionHandler:^(NSError *error){}];
When the completion handler is called, error is nil, meaning that it successfully deleted the match. The match does get deleted (it never re-appears), but at the same time, gamed (the background daemon written by apple that communicates with GameCenter servers) crashes.
Here is what I see in the Console when I delete a game:
Jan 19 20:47:22 Ben-L-iPhone gamed[2233] <Error>: *** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0xd000000000b4002a <x-coredata://C0390AE6-6CD0-4A7C-B080-B7649175419A/TurnBasedSession/p45>''
*** First throw call stack:
(0x185ce309c 0x191c61d78 0x1859eb7ac 0x1859fc50c 0x1859fc47c 0x185a7475c 0x185a79034 0x185a797f4 0x185a7a474 0x1922303e0 0x192235d88 0x185a6f3e4 0x185a7a104 0x1859fdbd0 0x100099284 0x185a71b6c 0x1922303e0 0x192235f2c 0x185a71d00 0x10009ce08 0x1000ba8a4 0x192230420 0x1922303e0 0x192235930 0x1922303e0 0x1922373fc 0x192237638 0x1923c5918 0x1923c57a8)
Jan 19 20:47:22 Ben-L-iPhone ReportCrash[2509] <Notice>: ReportCrash acting against PID 2233
Jan 19 20:47:22 Ben-L-iPhone ReportCrash[2509] <Notice>: Formulating crash report for process gamed[2233]
Jan 19 20:47:22 Ben-L-iPhone com.apple.launchd[1] (com.apple.gamed[2233]) <Warning>: (com.apple.gamed) Job appears to have crashed: Abort trap: 6
Jan 19 20:47:22 Ben-L-iPhone ReportCrash[2509] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/gamed_2014-01-19-204722_Ben-L-iPhone.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
Any ideas what could trigger this? I've searched the Apple Dev forums and Google and haven't been able to find someone with a similar problem.
Crash Report Logged
Incident Identifier: C201F189-7311-49E5-96F4-890A65FAA19A
CrashReporter Key: 0b745533f4a51b30bf9654557be6c063d06f1ccc
Hardware Model: iPhone6,1
Process: gamed [2233]
Path: /usr/libexec/gamed
Identifier: gamed
Version: ???
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2014-01-19 20:47:22.522 -0600
OS Version: iOS 7.0.4 (11B554a)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 11
Last Exception Backtrace:
0 CoreFoundation 0x185ce309c __exceptionPreprocess + 132
1 libobjc.A.dylib 0x191c61d78 objc_exception_throw + 60
2 CoreData 0x1859eb7ac _PFFaultHandlerLookupRow + 1900
3 CoreData 0x1859fc50c -[NSManagedObject(_NSInternalMethods) _newPropertiesForRetainedTypes:andCopiedTypes:preserveFaults:] + 108
4 CoreData 0x1859fc47c -[NSManagedObject(_NSInternalMethods) _newAllPropertiesWithRelationshipFaultsIntact__] + 108
5 CoreData 0x185a7475c -[NSManagedObjectContext(_NSInternalAdditions) _committedSnapshotForObject:] + 72
6 CoreData 0x185a79034 -[NSManagedObjectContext(_NestedContextSupport) _copyChildObject:toParentObject:fromChildContext:] + 144
7 CoreData 0x185a797f4 -[NSManagedObjectContext(_NestedContextSupport) _parentProcessSaveRequest:inContext:error:] + 1092
8 CoreData 0x185a7a474 __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke + 660
9 libdispatch.dylib 0x1922303e0 _dispatch_client_callout + 16
10 libdispatch.dylib 0x192235d88 _dispatch_barrier_sync_f_slow + 352
11 CoreData 0x185a6f3e4 _perform + 124
12 CoreData 0x185a7a104 -[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:] + 184
13 CoreData 0x1859fdbd0 -[NSManagedObjectContext save:] + 840
14 gamed 0x100099284 0x100048000 + 332420
15 CoreData 0x185a71b6c developerSubmittedBlockToNSManagedObjectContextPerform + 100
16 libdispatch.dylib 0x1922303e0 _dispatch_client_callout + 16
17 libdispatch.dylib 0x192235f2c _dispatch_barrier_sync_f_invoke + 48
18 CoreData 0x185a71d00 -[NSManagedObjectContext performBlockAndWait:] + 132
19 gamed 0x10009ce08 0x100048000 + 347656
20 gamed 0x1000ba8a4 0x100048000 + 469156
21 libdispatch.dylib 0x192230420 _dispatch_call_block_and_release + 24
22 libdispatch.dylib 0x1922303e0 _dispatch_client_callout + 16
23 libdispatch.dylib 0x192235930 _dispatch_async_redirect_invoke + 152
24 libdispatch.dylib 0x1922303e0 _dispatch_client_callout + 16
25 libdispatch.dylib 0x1922373fc _dispatch_root_queue_drain + 400
26 libdispatch.dylib 0x192237638 _dispatch_worker_thread2 + 76
27 libsystem_pthread.dylib 0x1923c5918 _pthread_wqthread + 356
28 libsystem_pthread.dylib 0x1923c57a8 start_wqthread + 4
Additional Information
I went back and added logging around the removeMatch. This logging is from the sandbox, but it happens in production too.
Notice, the game is already in a final state (status:GKTurnBasedMatchStatusEnded) right before the match is removed.
As soon as I removed the match, I tried to start a new match. The first try results in a "The operation couldn’t be completed. (Cocoa error 4097.)", the second try nearly 2 minutes later results in a GKServerStatusCode=5000 because the player is no longer authenticated.
2014-01-19 22:23:31.436 KingChase[3432:70b] removing match <GKTurnBasedMatch 0xc50d8f0 - matchID:e0e24a77-fb5c-46a7-b843-21e8becf9735 bundleID:us.pojo.kingchase status:GKTurnBasedMatchStatusEnded message:'Game Over! kctest2 won.' creationDate:2014-01-20 04:17:31 +0000 currentParticipant:(null) participants:<GKTurnBasedParticipant 0xc4e9870 - playerID:G:1972295489 (local player) status:Done matchOutcome:Won lastTurnDate:2014-01-20 04:22:50 +0000 timeoutDate:(null)>,<GKTurnBasedParticipant 0xc439aa0 - playerID:G:1972168157 status:Done matchOutcome:Lost lastTurnDate:2014-01-20 04:23:17 +0000 timeoutDate:(null)> matchData.length:438 matchDataMaximumSize:65536 exchanges:(null)>
2014-01-19 22:23:31.441 KingChase[3432:70b] Match removed.
2014-01-19 22:23:31.442 KingChase[3432:70b] Match cleaned up.
2014-01-19 22:23:40.681 KingChase[3432:70b] Match Making failed. Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)"
2014-01-19 22:25:30.053 KingChase[3432:70b] Match Making failed. Error Domain=GKErrorDomain Code=6 "The requested operation could not be completed because local player has not been authenticated." UserInfo=0xc527430 {GKServerStatusCode=5000, NSUnderlyingError=0xc5222b0 "The operation couldn’t be completed. status = 5000, missing required header: x-gk-player-id", NSLocalizedDescription=The requested operation could not be completed because local player has not been authenticated.}
The other player was able to delete the game without crashing gamed.
Updated Jan 20, 2014 - 6:32PM CDT - Further Information
I have added logging with every single interaction that I make with GameKit.
Jan 20 17:39:17 Ben-L-iPhone KingChase[3154] <Warning>: GK: [match.currentParticipant.playerID isEqualToString:localPlayer.playerID]
Jan 20 17:39:17 Ben-L-iPhone KingChase[3154] <Warning>: GK: [match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:completionHandler];
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: removing match <GKTurnBasedMatch 0x1669bdb0 - matchID:a182e163-8006-413e-a203-c93d534ac550 bundleID:us.pojo.kingchase status:GKTurnBasedMatchStatusEnded message:'Game Over! kctest1 won.' creationDate:2014-01-20 23:12:32 +0000 currentParticipant:(null) participants:<GKTurnBasedParticipant 0x166ae6f0 - playerID:G:1972168157 (local player) status:Done matchOutcome:Won lastTurnDate:2014-01-20 23:27:14 +0000 timeoutDate:(null)>,<GKTurnBasedParticipant 0x1664d260 - playerID:G:1972295489 status:Done matchOutcome:Lost lastTurnDate:2014-01-20 23:38:15 +0000 timeoutDate:(null)> matchData.length:390 matchDataMaximumSize:65536 exchanges:(null)>
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: GK: [match removeWithCompletionHandler:^(NSError *error)
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: Match removed.
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: Match cleaned up.
Jan 20 17:39:19 Ben-L-iPhone gamed[3125] <Error>: *** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0xd00000000024001a <x-coredata://3A4F66E1-B95C-4692-B905-EA1398FB97CE/TurnBasedSession/p9>''
*** First throw call stack:
(0x185ce309c 0x191c61d78 0x1859eb7ac 0x1859fc50c 0x1859fc47c 0x185a7475c 0x185a79034 0x185a797f4 0x185a7a474 0x1922303e0 0x192235d88 0x185a6f3e4 0x185a7a104 0x1859fdbd0 0x10014d284 0x185a71b6c 0x1922303e0 0x192235f2c 0x185a71d00 0x100150e08 0x10016e8a4 0x192230420 0x1922303e0 0x192235930 0x1922303e0 0x1922373fc 0x192237638 0x1923c5918 0x1923c57a8)
I think this now has to do with my calling
[match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:completionHandler];
after the game is already complete. I will test the hypothesis when I have time and submit the bug report to Apple.
I have figured out that this problem appears to happen when you call [match removeWithCompletionHandler:^(NSError *error)] from within the completion handler of another GameKit call.
If you look in the log above:
[match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:completionHandler];
is called, and the completionHandler for that method was calling -removeWithCompletionHandler:
I solved this problem using this change:
by executing the removeWithCompletionHandler in this manner:
[match performSelector:#selector(removeWithCompletionHandler:) withObject:^(NSError *error) {} afterDelay:5.0];

MFMessageComposeViewController messages disappear and fail to send after send button is pressed (iOS 7)

I have an app in which the user can select an image and send it to a friend by attaching the image to an instance of MFMessageComposeViewController. After pressing send in the MFMCVC view, things work as expected some of the time--the message with the image is successfully sent to the recipient or a "message failed" label shows up along side the message in the native iMessage client (but in both cases, the image is visible in the native client). However, there's a bug that occurs ~half the time after pressing send (on an iPhone 4 running iOS 7). The message--attachment and all--vanishes, never to be seen again. The recipient never receives the message and it does not appear in the sender's message channel in iMessage.
I'm fairly certain that this is a bug in Apple's MFMessageComposeViewController itself because the API is dead simple and I was able to reliably reproduce the bug in a separate demo app https://github.com/timcour/mf-message-compose-fail-demo.git.
- (void)displaySMSComposerSheet
{
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
NSData *data = [_imageDataCache objectForKey:[_imageURLs objectAtIndex:_currentIndex]];
[picker addAttachmentData:data
typeIdentifier:(NSString *)kUTTypeGIF
filename:#"share.gif"];
if (![self.recipientTextField.text isEqualToString:#""]) {
picker.recipients = [NSArray arrayWithObject:self.recipientTextField.text];
}
picker.body = [NSString stringWithFormat:#"image: %i", _currentIndex];
[self presentViewController:picker animated:YES completion:NULL];
}
After observing the UI during quite a few success and failure cases, it appears to be a race condition in the compose view exacerbated by the OS being stressed--not sure if it's memory or CPU stress (or both?). In any case, when sending is successful, the contents of the message channel are populated with its the contents of its respective conversation immediately after selecting a contact, visibly appending the new message to the end. But when the bug surfaces and the message disappears, the conversation's previous messages typically only appear after the send button is pressed without the new message appearing. If this is indeed a race condition, one guess is that it's a race between the composer VC's message fetching mechanism and -viewDidLoad.
Has anyone run across this before and/or know of a workaround? I will be submitting a bug report to apple, but I'd like to find a solution that does not include waiting for a fix from Apple.
Notes:
Messages vanish most frequently on iPhone 4 and iPhone 5s, but rarely on the iPod touch 5th generation (all running iOS 7.0.2).
The bug can be reproduced most easily using the https://github.com/timcour/mf-message-compose-fail-demo.git app on the iPhone 4 by sending the 20 images to the same person as fast as you can.
There is a separate (but probably related) bug. After selecting entering an email address of a contact in the MFMCVC view, the vc determines whether it should send an iMessage or MMS. Some of the time during testing, it made the wrong determination and attempted to send the message as an MMS despite the recipient iMessage account not having a phone number associated with it. This resulted in a message that looked to the sender like it was sent successfully, but which actually failed to reach its destination.
This does not seem to be the "iMessage fails to send messages" bug that many users have complained to Apple about.
UPDATE:
Here is the stacktrace that is logged when a message disappears and fails to send:
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] ****** Failed to complete all history queries in a blocking request: (
"********-****-****-****-************"
)
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 1 IMFoundation 0x0000000193acb948 IMLogBacktraceToDepth + 80
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 2 IMCore 0x00000001939d1df8 _NSStringFromIMMessageError + 22604
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 3 IMCore 0x00000001939c7670 IMPersonStatusComparator + 261116
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 4 ChatKit 0x00000001923c96b8 <redacted> + 240
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 5 ChatKit 0x00000001923933b0 <redacted> + 88
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 6 ChatKit 0x000000019237cb70 <redacted> + 996
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 7 ChatKit 0x0000000192414cdc <redacted> + 76
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 8 Foundation 0x000000018e8c0834 __NSFireDelayedPerform + 392
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 9 CoreFoundation 0x000000018dd1768c <redacted> + 28
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 10 CoreFoundation 0x000000018dd172fc <redacted> + 804
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 11 CoreFoundation 0x000000018dd15024 <redacted> + 1324
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 12 CoreFoundation 0x000000018dc55b78 CFRunLoopRunSpecific + 452
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 13 GraphicsServices 0x0000000193677830 GSEventRunModal + 168
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 14 UIKit 0x0000000190c9305c UIApplicationMain + 1156
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 15 MessagesViewService 0x000000010009bd80 MessagesViewService + 15744
Oct 21 12:09:17 Davids-iPhone MessagesViewService[2680] <Warning>: [Warning] 16 libdyld.dylib 0x000000019a25baa0 <redacted> + 4
Oct 21 12:09:20 Davids-iPhone SpringBoard[16] <Warning>: LICreateIconForImage passed NULL CGImageRef image
Your problem is that you do not have a strong reference to picker. Make that an ivar, and nil it when the picker has totally completed its work.
Try to make sure your time and date is set correctly. I altered mine to download an emulator and forgot to change it back after. My messages then started to disappear. After I fixed the time the problem was corrected. Cheers

EXC_BAD_ACCESS (code=1, address=0x0) when stepping in debugger

My application crashes each and every time I try to step over a call. Without debugger it works fine.
Also, when I run the app in simulator it woks fine with or without debugger.
Recently I upgraded my Mac OS X 10.8 to 10.9 (Mavericks). There were no issues before the upgrade.
What causes the issue and how could I fix it?
Below is the back trace. My app uses ARC. I have enabled zombies and added exception breakpoint but no zombies where detected and exception breakpoint is never triggered.
* thread #1: tid = 0x2503, 0x00000000, queue = 'com.apple.main-thread, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x00000000
frame #1: 0x35e170c4 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 72
frame #2: 0x35e17076 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
frame #3: 0x35e17054 UIKit`-[UIControl sendAction:to:forEvent:] + 44
frame #4: 0x35e1690a UIKit`-[UIControl(Internal) _sendActionsForEvents:withEvent:] + 502
frame #5: 0x35e16e00 UIKit`-[UIControl touchesEnded:withEvent:] + 488
frame #6: 0x35d3f5f0 UIKit`-[UIWindow _sendTouchesForEvent:] + 524
frame #7: 0x35d2c800 UIKit`-[UIApplication sendEvent:] + 380
frame #8: 0x35d2c11a UIKit`_UIApplicationHandleEvent + 6154
frame #9: 0x37a1e5a2 GraphicsServices`_PurpleEventCallback + 590
frame #10: 0x37a1e1d2 GraphicsServices`PurpleEventCallback + 34
frame #11: 0x33ef9172 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
frame #12: 0x33ef9116 CoreFoundation`__CFRunLoopDoSource1 + 138
frame #13: 0x33ef7f98 CoreFoundation`__CFRunLoopRun + 1384
frame #14: 0x33e6aebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #15: 0x33e6ad48 CoreFoundation`CFRunLoopRunInMode + 104
frame #16: 0x37a1d2ea GraphicsServices`GSEventRunModal + 74
frame #17: 0x35d80300 UIKit`UIApplicationMain + 1120
frame #18: 0x000faac8 MyApp`main(argc=1, argv=0x2fd0fd08) + 116 at main.m:16
EDIT:
I have latest Xcode Version 5.0.1 (5A2053).
I have created new app from scratch and ran it without issues. Then I put a breakpoint in ViewController's viewDidLoad and tried to step over. Here I got another crash
* thread #1: tid = 0x2503, 0x3bb9d7c4 libobjc.A.dylib`objc_msgSendSuper2 + 4, queue = 'com.apple.main-thread, stop reason = EXC_BAD_ACCESS (code=1, address=0x4)
frame #0: 0x3bb9d7c4 libobjc.A.dylib`objc_msgSendSuper2 + 4
frame #1: 0x000b913a test`-[ViewController viewDidLoad](self=0x1cda5c70, _cmd=0x361bd5db) + 62 at ViewController.m:19
frame #2: 0x35d4b594 UIKit`-[UIViewController loadViewIfRequired] + 364
frame #3: 0x35d8bd78 UIKit`-[UIWindow addRootViewControllerViewIfPossible] + 64
frame #4: 0x35d87aec UIKit`-[UIWindow _setHidden:forced:] + 364
frame #5: 0x35dc91e8 UIKit`-[UIWindow makeKeyAndVisible] + 60
frame #6: 0x35d8c83e UIKit`-[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1666
frame #7: 0x35d8484a UIKit`-[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 698
frame #8: 0x35d2cc38 UIKit`-[UIApplication handleEvent:withNewEvent:] + 1004
frame #9: 0x35d2c6cc UIKit`-[UIApplication sendEvent:] + 72
frame #10: 0x35d2c11a UIKit`_UIApplicationHandleEvent + 6154
frame #11: 0x37a1e5a2 GraphicsServices`_PurpleEventCallback + 590
frame #12: 0x37a1e1d2 GraphicsServices`PurpleEventCallback + 34
frame #13: 0x33ef9172 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
frame #14: 0x33ef9116 CoreFoundation`__CFRunLoopDoSource1 + 138
frame #15: 0x33ef7f98 CoreFoundation`__CFRunLoopRun + 1384
frame #16: 0x33e6aebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #17: 0x33e6ad48 CoreFoundation`CFRunLoopRunInMode + 104
frame #18: 0x35d83484 UIKit`-[UIApplication _run] + 668
frame #19: 0x35d80300 UIKit`UIApplicationMain + 1120
frame #20: 0x000b93bc test`main(argc=1, argv=0x2fd51d30) + 116 at main.m:16
frame #21: 0x3bfd9b20 libdyld.dylib`start + 4
EDIT 2:
Greg Clayton in the XCode 5 Crashes while running the app on device suggests following
Others have seen this issue.
A few things to try:
1 - Reboot your device and try again. The theory is an old developer disk image is already mounted and won't be unmounted until you reboot.
2 - Re-install the OS on the device
Hopefully #1 fixes your issue. Others have done #2 and had their issue fixed, but hopefully it doesn't require an OS re-install.
I did both and it didn't help.
I tried to use another device and it made a difference. Exceptions are still there if I use iPod Touch with iOS 6.1 but iPad with iOS 7.0.2 works fine.
So, it looks like the issue is related to the iOS version installed on the device. I am still not sure what to do to fix it.
EDIT 3:
My Command Line Tools version matches my Xcode version (I have only one version of Command Line Tools, actually).
The issues is probably not related to the code being debugged. It crashes with newly created Single View Application created by Xcode. And it crashes when stepping over trivial code:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
I have asked on Apple Developer Forum and got following response from Jason Molenda:
We're tracking a bug that sounds like what you're seeing here. It is
a subtle timing issue that requires a slightly slower host machine or
a slightly slower device to hit. It is primarily iPhone 4 and similar
that will see this with iOS 7. With iOS 6, iPhone 4 and iPhone 3GS
devices are most likely to experience it. ... This issue will only
happen with Xcode 5.0.1.
So, it seems like it's a bug in Xcode.
Ok, this is definitely a bug in Xcode 5.0.1.
This is confirmed by Jason Molenda on Apple Developer Forum. The only workaround for now is to use older version of Xcode and the older version of Mac OS X because Xcode 5 requires OS X 10.8.4.
There is no announced ETA for a fix for this issue. Direct question about ETA on Apple Developer Forum is left without answer.
UPDATE 06-Nov-2013:
Today a pre-release version of Xcode 5.0.2 became available on developer.apple.com. This version fixes (among other things) the following issue:
Debugging an application on a device running iOS 6.x causes the
application to crash with EXC_BAD_ACCESS.  This has been resolved.
(15310896)
I have installed the new version and the issue is indeed gone. Now I am able to debug apps on my 6.x devices again.
Jason Molenda in thread on Apple Developer Forum said:
I'm told you can submit apps to the app store with this Xcode 5.0.2
seed.
I confirm I have exactly same bug. My App worked fine.
After upgrade to Xcode 5 and Mavericks code work but when I debug I can't Step Over certain lines as I get EXC_BAD_ACCESS.
So I have to remember lines that I can't pass with Step Over and put break point after these lines or use Continue to Line to jump over these problematic lines.
PS
Downloaded Xcode 5.0.2 GM seed and debugging is much better. I spent 30 minutes with new Xcode so far.
Please login developer site and download the Xcode 5.0.2 GM seed, it fixed this bug.
See the release notes.
Update 12-Nov-2013
Xcode 5.0.2 has released, you can download it from Dev Center

MQMapKit (MapQuest) IOS 6 crashing

I had a working MKMapKit working in an app Im working on and decided to
convert it to MapQuest's MQMapKit which is supposed to be a drop-in replacement from
what I understand. After doing so (and checking for any 'MK' map stuff...which I dont
believe I have any now, they are all 'MQ' map references), Im getting the following
crash when the app tries to start up. Im not sure where 'prepareKeyForNewAnimation'
comes from. It seems to me to be a MapQuest Library issue (which is version 1.0.1).
Any ideas what is causing this or how to fix it? Thanks for any help on this!
013-05-28 07:01:23.394 myapp[25100:14003] === set USER center
2013-05-28 07:01:23.394 myapp[25100:14003] spanVal <0.300000>
2013-05-28 07:01:23.503 myapp[25100:14003] -[CALayer prepareKeyForNewAnimation:]: unrecognized selector sent to instance 0x85781e0
2013-05-28 07:01:23.504 myapp[25100:14003] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer prepareKeyForNewAnimation:]: unrecognized selector sent to instance 0x85781e0'
*** First throw call stack:
(0x1ec7012 0x1c3ae7e 0x1f524bd 0x1eb6bbc 0x1eb694e 0x55e9b 0x248053f 0x2492014 0x24827d5 0x1e6daf5 0x1e6cf44 0x1e6ce1b 0x2efe7e3 0x2efe668 0xb7effc 0x2042 0x1f75)
libc++abi.dylib: terminate called throwing an exception
backtrace:
* thread #1: tid = 0x1f03, 0x9bca39c6 libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGABRT
frame #0: 0x9bca39c6 libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x90065f78 libsystem_c.dylib`pthread_kill + 106
frame #2: 0x0250157b libsystem_sim_c.dylib`abort + 140
frame #3: 0x02413f7b libc++abi.dylib`abort_message + 105
frame #4: 0x02411a25 libc++abi.dylib`default_terminate() + 34
frame #5: 0x01c3b0c1 libobjc.A.dylib`_objc_terminate() + 94
frame #6: 0x02393652 libstdc++.6.0.9.dylib`std::terminate() + 21
frame #7: 0x01c3b039 libobjc.A.dylib`objc_terminate + 11
frame #8: 0x02492027 libdispatch.dylib`_dispatch_client_callout + 33
frame #9: 0x024827d5 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 296
frame #10: 0x01e6daf5 CoreFoundation`__CFRunLoopRun + 1925
frame #11: 0x01e6cf44 CoreFoundation`CFRunLoopRunSpecific + 276
frame #12: 0x01e6ce1b CoreFoundation`CFRunLoopRunInMode + 123
frame #13: 0x02efe7e3 GraphicsServices`GSEventRunModal + 88
frame #14: 0x02efe668 GraphicsServices`GSEventRun + 104
frame #15: 0x00b7effc UIKit`UIApplicationMain + 1211
frame #16: 0x00002042 myapp`main(argc=1, argv=0xbffff364) + 130 at main.m:16
frame #17: 0x00001f75 myapp`start + 53
[EDIT] Very bizarre. This was happening in the simulator on ipad. I tried plugging
in my iphone 5 and I got a provisioning error (even though it worked earlier and shouldnt
have been an issue. When I edited the dev profile and added a couple other users that
I had and re-downloaded it, it still didnt work. When I went into the settings and changed
the debug/release/distro settings to the generic 'Developer profile' for all three it
now worked fine without crashing. Bizarre!
[EDIT] NOT so solved....still crashing on and off, mostly on. Any help would be
appreciated.
[SOLVED] Found this article where I missed adding -ObjC to 'Other Linker Flags':
mapquest developer site

NSURLCache crashes under iOS 6.1

Using iOS 6.1 my App crashes regulary, directly after startup, when it attempts to make several HTTP-Requests, but it works fine on any OS < 6.1.
I'm experiencing
EXC_BAD_ACCESS crashes in the strlen function called from the Queue : com.apple.CFURLCACHE_work_queue, everytime my App is started, except for the first time.
I could resolve the issue by clearing the NSURLCache, directly after the app started:
[[NSURLCache sharedURLCache] removeAllCachedResponses];
Does anyone else experience these crashes? Could there be some issue in the application code causing these crashes? Or should this be a bug filed to apple?
Experiencing a similar crash since iOS 6.1 with a newly installed application. The difference is that the crash occurs when tapping a text cell in a table view. No web requests are being made at this time.
This is the bt:
thread #4: tid = 0x2903, 0x3ae7ad74 libsystem_c.dylib`strlen + 28, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x3ae7ad74 libsystem_c.dylib`strlen + 28
frame #1: 0x3ac6be24 libsqlite3.dylib`___lldb_unnamed_function282$$libsqlite3.dylib + 1232
frame #2: 0x3ac74a5e libsqlite3.dylib`sqlite3_file_control + 174
frame #3: 0x328493fe CFNetwork`__CFURLCache::RecreateEmptyPersistentStoreOnDiskAndOpen_NoLock() + 30
frame #4: 0x32849000 CFNetwork`__CFURLCache::RecreateEmptyPersistentStoreOnDiskAndOpen() + 44
frame #5: 0x327f9488 CFNetwork`__CFURLCache::OpenDatabase() + 192
frame #6: 0x32846a72 CFNetwork`__CFURLCache::ProcessCacheTasks0(bool) + 358
frame #7: 0x32846900 CFNetwork`__CFURLCache::ProcessCacheTasks(bool) + 36
frame #8: 0x3284681e CFNetwork`__CFURLCache::_CFURLCacheTimerCallback0() + 358
frame #9: 0x328466ac CFNetwork`__CFURLCache::_CFURLCacheTimerCallback(void*) + 32
frame #10: 0x328490fc CFNetwork`__SignalWorkerTaskToPerformWork_block_invoke_0 + 12
frame #11: 0x3ae4611e libdispatch.dylib`_dispatch_call_block_and_release + 10
frame #12: 0x3ae49ece libdispatch.dylib`_dispatch_queue_drain$VARIANT$mp + 142
frame #13: 0x3ae49dc0 libdispatch.dylib`_dispatch_queue_invoke$VARIANT$mp + 40
frame #14: 0x3ae4a91c libdispatch.dylib`_dispatch_root_queue_drain + 184
frame #15: 0x3ae4aac0 libdispatch.dylib`_dispatch_worker_thread2 + 84
frame #16: 0x3ae7aa10 libsystem_c.dylib`_pthread_wqthread + 360
frame #17: 0x3ae7a8a4 libsystem_c.dylib`start_wqthread + 8
Reported this as a TSI to Apple, it was reviewed and they requests that I log this as a bug, still need to do this.
Interestingly enough the solution which you found also helped me, clearing the cache at launch solved this problem.
This is only half an answer, but I'm running into a very similar problem whilst running my unit tests. Bizarrely, this only seemed to start happening today.
The full details of my issue are outlined in this Apple dev forums thread.
The common link between our problems appears to be the call to RecreateEmptyPersistentStoreOnDiskAndOpen_NoLock(). If my understanding of CFURLCache is correct, and based on the backtrace, it uses a sqlite3 database internally as a cache. I'd assume this function call creates the empty sqlite3 database on disk.
I was able to repeatedly and consistently stop my tests crashing by deleting the simulator's Library/Caches directory (~/Library/Application Support/iPhone Simulator/6.1/Library/Caches) and make the crash return by re-creating that directory.
Deleting the entire simulator home directory and letting it be recreated by launching my app in the simulator would also fix and re-create the issue.
I'm guessing this is an OS bug; the curious thing is why for me, it only just started happening.

Resources