MQMapKit (MapQuest) IOS 6 crashing - ios

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

Related

Crash on exporting file via UIActivityViewController

The following code exports a file from my app's 'tmp' folder to other apps using UIActivityViewController.
private func exportFile(_ fileURL: URL) {
let items: [Any] = [fileURL]
let activityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
present(activityViewController, animated: true, completion: nil)
}
This code was working fine and I could export to iCloud, Google Drive, Mail, Outlook and iZip (the latter using 'Copy to iZip').
However, my app has recently started crashing after selecting 'Copy to iZip' when exporting, though exporting to the other apps works fine. Between it working and crashing there have been updates to iOS, iZip and my app.
Crashlytics reports the following, but this looks deep in iOS and it's difficult to know what the root cause of the problem is:
Fatal Exception: NSInvalidArgumentException
*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
ShareSheet __79-[UIActivityViewController willPerformInServiceActivityWithRequest:completion:]_block_invoke_3
This occurs on an iPhone running iOS 13.3.1
Debugger report on breaking on NSInvalidArgumentException:
> (lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000189ffdf6c libobjc.A.dylib`objc_exception_throw
frame #1: 0x000000018a32c360 CoreFoundation`_CFThrowFormattedException + 112
frame #2: 0x000000018a32b9f4 CoreFoundation`-[__NSArrayM insertObject:atIndex:].cold.1 + 48
frame #3: 0x000000018a1ae120 CoreFoundation`-[__NSArrayM insertObject:atIndex:] + 1104
frame #4: 0x0000000195914e80 ShareSheet`__79-[UIActivityViewController willPerformInServiceActivityWithRequest:completion:]_block_invoke_3 + 1512
frame #5: 0x00000001089497fc libdispatch.dylib`_dispatch_call_block_and_release + 24
frame #6: 0x000000010894abd8 libdispatch.dylib`_dispatch_client_callout + 16
frame #7: 0x0000000108958c34 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1316
frame #8: 0x000000018a2545e4 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
frame #9: 0x000000018a24f5d8 CoreFoundation`__CFRunLoopRun + 2004
frame #10: 0x000000018a24eadc CoreFoundation`CFRunLoopRunSpecific + 464
frame #11: 0x00000001941ef328 GraphicsServices`GSEventRunModal + 104
frame #12: 0x000000018e35c63c UIKitCore`UIApplicationMain + 1936
* frame #13: 0x00000001024f1078 xApp`main at AppDelegate.swift:41:7
frame #14: 0x000000018a0d8360 libdyld.dylib`start + 4
(lldb)
Code at frame #4 breakpoint (0x195914e80):
> WTFLogLevel, WTF::Logger::LogSiteIdentifier const&, char const (&) [7], unsigned long const&) (.cold.1)
0x195914e80 <+1512>: mov x28, x23
0x195914e84 <+1516>: ldr x0, [x23, #0xba0]
0x195914e88 <+1520>: ldr x1, [sp, #0x38]
0x195914e8c <+1524>: mov x2, x25
0x195914e90 <+1528>: mov x3, x20
0x195914e94 <+1532>: bl 0x193904be4 ; symbol stub
Any idea what the problem might be? I'm not sure whether it's a problem with my app, iOS or iZip.
Thanks to the suggestion from #koen, I contacted iZip support and had a very quick and helpful response. It also ties in with #WILL K. 's suggestion of trying a different directory.
The problem basically seems to be associated with directory permissions. Apparently some apps like iZip open the shared file in situ and so need permission to do so. As can be seen here https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html , the Documents/ directory "can be made available to the user through file sharing" whereas the tmp/ directory is more restricted.
So instead of using the tmp/ directory I tried using the Documents/ directory and the problem was solved. Thanks to iZip support for their rapid response and highlighting the issue with permissions.
For interest, on using the /Documents folder, more options came up for sharing with other apps.
There is also a useful article on how app extensions work (host apps, app extensions and container apps) here:
https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionOverview.html

How do I debug: libc++abi.dylib: terminating with uncaught exception of type NSException?

Sorry for asking this noob question, I know it has been asked thousands of times before, I know because I've had this problem thousands of times before. But this time google isn't helping.
The error / terminal print:
libc++abi.dylib: terminating with uncaught exception of type NSException
I generally know what type of situations cause this because I have had this issue in the past and it was quite simple to fix, usually a misnamed function or a broken link between some UI element and my code, but right now I have no idea what could be causing it.
What I have already tried:
I've added tonnes of breakpoints on the starting ViewController and it goes through all the #IBOutlets without throwing any issues. I've added breakpoints in all the methods in the AppDelegate and it doesn't break anywhere there. The code crashes before it reaches any viewDidLoad() methods. I've cleaned my project, restarted XCode a thousand times and even broken and re-made every link between UI and code. Renamed and then reassigned every #IBAction.
At this point I don't even know what I haven't tried. Every stackoverflow posts is always about the same thing "check broken links etc" but that just isn't helping anymore. I can't remember what it was that I changed because I changed so many small things before I started getting this error. I tried putting everything back but that didn't seem to help.
When the app crashes:
Right after "applicationDidBecomeActve()" is finished the debugger goes into a bunch of machine code, then the app crashes and I get this:
Proof of correct linking:
[Images removed as they were unneccessary]
My main question(s):
If linking is not the issue here, what else could it be?
About NSLogs/stack traces
I would love to provide some sort of NSLog or stack trace as I have seen people ask and give for on other questions but I have no idea how. I cannot find anything on the internet that isn't from the stone age on how to turn them on. And everything else is just how to use the debugger, but I am using the debugger and all I am getting are brief glimpses of my code in a see of machine instructions until it finally just crashes.
EDIT:
Apparently I can only get logs when running on an emulator instead of physical device. Here are the logs I get when running on emulator:
objc[40258]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x123242998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x123067d38). One of the two will be used. Which one is undefined.
2016-11-04 16:26:47.463 KotConnect[40258:1345011] Unknown class ProgressViewContainer in Interface Builder file.
2016-11-04 16:26:47.500 KotConnect[40258:1345011] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIView 0x7fbfe3c0a030> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key loadingView.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001105ca34b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000011002b21e objc_exception_throw + 48
2 CoreFoundation 0x00000001105ca299 -[NSException raise] + 9
3 Foundation 0x000000010fb3b26f -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
4 UIKit 0x0000000110e0580d -[UIView(CALayerDelegate) setValue:forKey:] + 173
5 UIKit 0x000000011114f79e -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000011056f590 -[NSArray makeObjectsPerformSelector:] + 256
7 UIKit 0x000000011114e122 -[UINib instantiateWithOwner:options:] + 1867
8 UIKit 0x0000000110ee1c21 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
9 UIKit 0x0000000110ee2543 -[UIViewController loadView] + 177
10 UIKit 0x0000000110ee2878 -[UIViewController loadViewIfRequired] + 201
11 UIKit 0x0000000110f2307b -[UINavigationController _layoutViewController:] + 55
12 UIKit 0x0000000110f23963 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 471
13 UIKit 0x0000000110f23ada -[UINavigationController _startTransition:fromViewController:toViewController:] + 133
14 UIKit 0x0000000110f24ce5 -[UINavigationController _startDeferredTransitionIfNeeded:] + 874
15 UIKit 0x0000000110f25dc7 -[UINavigationController __viewWillLayoutSubviews] + 58
16 UIKit 0x000000011111cd6f -[UILayoutContainerView layoutSubviews] + 223
17 UIKit 0x0000000110e05f50 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
18 QuartzCore 0x0000000110ac3cc4 -[CALayer layoutSublayers] + 146
19 QuartzCore 0x0000000110ab7788 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
20 QuartzCore 0x0000000110ab7606 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
21 QuartzCore 0x0000000110a45680 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
22 QuartzCore 0x0000000110a72767 _ZN2CA11Transaction6commitEv + 475
23 QuartzCore 0x0000000110a730d7 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
24 CoreFoundation 0x000000011056ee17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
25 CoreFoundation 0x000000011056ed87 __CFRunLoopDoObservers + 391
26 CoreFoundation 0x00000001105534b6 CFRunLoopRunSpecific + 454
27 UIKit 0x0000000110d3b7e6 -[UIApplication _run] + 434
28 UIKit 0x0000000110d41964 UIApplicationMain + 159
29 KotConnect 0x000000010d52cc8f main + 111
30 libdyld.dylib 0x00000001135c968d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Swift
Just add
NSSetUncaughtExceptionHandler { exception in
print(exception)
print(exception.callStackSymbols)
}
at the bottom of didFinishLaunchingWithOptions method of AppDelegate. It will give you the better info about the exception occurred.
Happy coding !
Once I was able to see my app log I could see my custom class was not being found. I'll leave the fix I found for this issue for any people who have this issue in the future:
Xcode 6 Strange Bug: Unknown class in Interface Builder file
This happened to me when I accidentaly removed one of my storyboards from my targets. Make sure to double check your Target Membership.

SIGABRT crash on the first line

I have an iOS app which was running fine until yesterday and suddenly started to crash with Thread 1: signal SIGABRT at this point:
class AppDelegate: UIResponder, UIApplicationDelegate {
Having no idea of the cause I typed bt in the debugging console and got this:
(lldb) bt
* thread #1: tid = 0xda342, 0x0000000194637270 libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x0000000194637270 libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x00000001946d5170 libsystem_pthread.dylib`pthread_kill + 112
frame #2: 0x00000001945aeb18 libsystem_c.dylib`abort + 112
frame #3: 0x000000018badf2ec GraphicsServices`_GSRegisterPurpleNamedPortInPrivateNamespace + 424
frame #4: 0x000000018bade1d4 GraphicsServices`_GSEventInitializeApp + 140
frame #5: 0x0000000186c86c38 UIKit`UIApplicationMain + 712
* frame #6: 0x00000001000592f0 TheApp`main + 164 at AppDelegate.swift:13
frame #7: 0x000000019451ea08 libdyld.dylib`start + 4
(lldb)
Browsing the net for similar issues I have read it may be due to some problems related to the StoryBoard, but since I am doing everything programmatically I have some doubts that it applies to my case. I have also tried to use an exception break point just in case, but with no success.
I have even remade the project, the problem is still there. It seems something goes wrong even before my code starts to execute. I wonder what I can check.
Anyway if someone can give me a hint on what may be the issue, or on how to further investigate, that would be much appreciated.

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

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