iOS 8 crashing in a weird pattern - ios

I have spent over a ton of hours working on an app, it works perfectly on iOS 7, both on device and simulator. When I run it on iOS 8, it works perfectly on simulator. But for some reason, when I run it on my iOS 8 device, it starts crashing weirdly. If I implement CLLocation, the app will run smoothly for the first 5 times that I run it. Then it will crash the MOMENT I compile it for the next 5 times. After that 5 times, it starts compiling smoothly again. Then after 5 more times, it crashes on launch again, and the pattern continues.
IE. 1, run. 2. run. 3. run. 4. run. 5. run. 6-10.crash on launch, 11-15, run. 16-20 crash
HOWEVER, when I remove CLLocation, the app runs smoothly, but crashes on every 3rd launch. IE. 1. run. 2. run. 3. crash. 4. run. 5. run 6. crash.
I have been banging my head against the wall for like days without sleep on this. Can someone please explain to me why? For every crash on launch, the only error the console outputs is NSDictionary unknown selector.
I don't want my app to get rejected if Apple reviewers happen to run it at one of the "crash times"
Console Bt
(lldb) bt
* thread #3: tid = 0x12646, 0x00000001983640a8 libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.root.default-qos', stop reason = breakpoint 1.1
frame #0: 0x00000001983640a8 libobjc.A.dylib`objc_exception_throw
frame #1: 0x0000000187d8d094 CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:] + 220
frame #2: 0x0000000187d89e48 CoreFoundation`___forwarding___ + 928
frame #3: 0x0000000187c8f08c CoreFoundation`_CF_forwarding_prep_0 + 92
frame #4: 0x0000000188c4f0dc Foundation`-[NSString getExternalRepresentation:extendedAttributes:forWritingToURLOrPath:usingEncoding:error:] + 192
frame #5: 0x0000000188c4f23c Foundation`writeStringToURLOrPath + 72
* frame #6: 0x00000001000c9f1c Blurtalk`+[PFInternalUtils installationId](self=<unavailable>, _cmd=<unavailable>) + 340 at PFInternalUtils.m:307
frame #7: 0x00000001000f0a94 Blurtalk`+[PFNetworkCommandRunner createRequest:](self=0x000000010027d1b8, _cmd=<unavailable>, command=0x0000000170056a70) + 268 at PFNetworkCommandRunner.m:61
frame #8: 0x00000001000f1044 Blurtalk`+[PFNetworkCommandRunner runCommandAsync:inOperation:](self=0x000000010027d1b8, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 196 at PFNetworkCommandRunner.m:132
frame #9: 0x00000001000f1748 Blurtalk`+[PFRetryingCommandRunner runCommandAsync:inOperation:attemptsMade:delay:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, attemptsMade=1, delay=<unavailable>) + 92 at PFRetryingCommandRunner.m:42
frame #10: 0x00000001000f16bc Blurtalk`+[PFRetryingCommandRunner runCommandAsync:inOperation:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 124 at PFRetryingCommandRunner.m:35
frame #11: 0x00000001000f1f80 Blurtalk`+[PFCachedCommandRunner runCommandAsync:inOperation:cachePolicy:maxCacheAge:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, cachePolicy=<unavailable>, maxCacheAge=<unavailable>) + 240 at PFCachedCommandRunner.m:82
frame #12: 0x000000010009dcd8 Blurtalk`__48-[BFTask continueWithExecutor:withSuccessBlock:]_block_invoke(.block_descriptor=0x0000000170241e60, task=<unavailable>) + 200 at BFTask.m:335
frame #13: 0x000000010009d730 Blurtalk`__41-[BFTask continueWithExecutor:withBlock:]_block_invoke_2(.block_descriptor=0x000000017807a340) + 32 at BFTask.m:287
frame #14: 0x0000000100338f20 libdispatch.dylib`_dispatch_call_block_and_release + 24
frame #15: 0x0000000100338ee0 libdispatch.dylib`_dispatch_client_callout + 16
frame #16: 0x00000001003459a0 libdispatch.dylib`_dispatch_root_queue_drain + 1272
frame #17: 0x0000000100346f18 libdispatch.dylib`_dispatch_worker_thread3 + 132
frame #18: 0x0000000198b852e4 libsystem_pthread.dylib`_pthread_wqthread + 816

I have been able to reproduce and narrow down your crash using NSZombieEnabled.
My backtrace:
2014-12-30 14:58:26.997 Proto[1398:513570] *** -[CFString getExternalRepresentation:extendedAttributes:forWritingToURLOrPath:usingEncoding:error:]: message sent to deallocated instance 0x170e78fc0
(lldb) bt
* thread #7: tid = 0x7d622, 0x00000001864be440 CoreFoundation`___forwarding___ + 968, queue = 'com.apple.root.default-qos', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1864be440)
* frame #0: 0x00000001864be440 CoreFoundation`___forwarding___ + 968
frame #1: 0x00000001863c2b6c CoreFoundation`_CF_forwarding_prep_0 + 92
frame #2: 0x000000018738a83c Foundation`writeStringToURLOrPath + 72
frame #3: 0x00000001002485bc Proto`+[PFInternalUtils installationId](self=<unavailable>, _cmd=<unavailable>) + 340 at PFInternalUtils.m:308
frame #4: 0x000000010028a944 Proto`+[PFNetworkCommandRunner createRequest:](self=0x000000010054eea8, _cmd=<unavailable>, command=0x0000000170446990) + 308 at PFNetworkCommandRunner.m:62
frame #5: 0x000000010028aef4 Proto`+[PFNetworkCommandRunner runCommandAsync:inOperation:](self=0x000000010054eea8, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 196 at PFNetworkCommandRunner.m:133
frame #6: 0x000000010028b5fc Proto`+[PFRetryingCommandRunner runCommandAsync:inOperation:attemptsMade:delay:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, attemptsMade=1, delay=<unavailable>) + 92 at PFRetryingCommandRunner.m:42
frame #7: 0x000000010028b570 Proto`+[PFRetryingCommandRunner runCommandAsync:inOperation:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 124 at PFRetryingCommandRunner.m:35
frame #8: 0x000000010028be40 Proto`+[PFCachedCommandRunner runCommandAsync:inOperation:cachePolicy:maxCacheAge:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, cachePolicy=<unavailable>, maxCacheAge=<unavailable>) + 248 at PFCachedCommandRunner.m:83
frame #9: 0x00000001001ad038 Proto`__48-[BFTask continueWithExecutor:withSuccessBlock:]_block_invoke(.block_descriptor=0x0000000170446ea0, task=<unavailable>) + 200 at BFTask.m:335
frame #10: 0x00000001001aca90 Proto`__41-[BFTask continueWithExecutor:withBlock:]_block_invoke_2(.block_descriptor=0x0000000171067b40) + 32 at BFTask.m:287
frame #11: 0x0000000100ab8e30 libdispatch.dylib`_dispatch_call_block_and_release + 24
frame #12: 0x0000000100ab8df0 libdispatch.dylib`_dispatch_client_callout + 16
frame #13: 0x0000000100ac59a0 libdispatch.dylib`_dispatch_root_queue_drain + 1280
frame #14: 0x0000000100ac6f18 libdispatch.dylib`_dispatch_worker_thread3 + 132
frame #15: 0x00000001974312e4 libsystem_pthread.dylib`_pthread_wqthread + 816
This is a bug in the Parse SDK, specifically when Parse tries to get device information on an initial install. I suggest you report this bug to Parse directly and point them to this StackOverflow question.
Additional conversation here: Parse Objective C library crashes on [PFInternalUtils installationId]
EDIT: There is an open bug report for this issue here: https://developers.facebook.com/bugs/1548203598729083

you should create an one for all breakpoint that will stop on any exception, please read this article, it is a very useful technique.
http://blog.manbolo.com/2012/01/23/xcode-tips-1-break-on-exceptions
by the way, NSDictionary does not have length, it seems like you made a mistake by confusing it with a NSString object.

Related

lldb Xcode Error CoreBluetooth

I have an app using CoreBluetooth. When I select a Bluetooth device to connect, I get the lldb error with the following backtrace:
* thread #1: tid = 0x2818f, 0x000000018207dbd0 libobjc.A.dylib`objc_msgSend + 16, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
frame #0: 0x000000018207dbd0 libobjc.A.dylib`objc_msgSend + 16
frame #1: 0x00000001882e8ee0 CoreBluetooth`__29-[CBXpcConnection handleMsg:]_block_invoke + 60
frame #2: 0x0000000101191bf0 libdispatch.dylib`_dispatch_call_block_and_release + 24
frame #3: 0x0000000101191bb0 libdispatch.dylib`_dispatch_client_callout + 16
frame #4: 0x0000000101197658 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 2096
frame #5: 0x00000001829b4bb0 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
frame #6: 0x00000001829b2a18 CoreFoundation`__CFRunLoopRun + 1628
frame #7: 0x00000001828e1680 CoreFoundation`CFRunLoopRunSpecific + 384
frame #8: 0x0000000183df0088 GraphicsServices`GSEventRunModal + 180
frame #9: 0x0000000187758d90 UIKit`UIApplicationMain + 204
* frame #10: 0x0000000100039adc BluetoothLE`main + 136 at AppDelegate.swift:13
frame #11: 0x00000001824828b8 libdyld.dylib`start + 4
The strange thing is I only get this on my iPad mini 4, not on my iPhone 6...
Please can anybody help me resolve this issue?
Thanks in advance
Did you check in the Device Console in Xcode to see if there are any illuminating messages? iOS tends to use daemon processes to handle services like bluetooth, and error messages from them won't go to the regular Xcode debugging console since they aren't hooked up to the stdout of your program. They will go to the Device Console. That is in the Devices window, select your device and there is a little disclosure widget on the LLHS of the window that reveals the device console.

Swift 2.0 Random EXC_BAD_ACCESS

I'm running into some really strange EXC_BAD_ACCESS crashes which are totally reproducible with the last 2 Xcode 7 Beta versions (including the GM from last night):
When running my application, AFNetworking crashes with an EXC_BAD_ACCESS message in AFURLConnectionOperation.m line 154. More precisely, here is the stacktrace:
thread #1: tid = 0x23b173, 0x000000010b89beaf CoreFoundation`___forwarding___ + 767, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
frame #0: 0x000000010b89beaf CoreFoundation`___forwarding___ + 767
frame #1: 0x000000010b89bb28 CoreFoundation`__forwarding_prep_0___ + 120
* frame #2: 0x0000000105a4507e MyApp`-[AFURLConnectionOperation .cxx_destruct](self=0x00007fc4d873aa20, _cmd=(null)) + 494 at AFURLConnectionOperation.m:154
frame #3: 0x000000010af637bb libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 127
frame #4: 0x000000010af6e390 libobjc.A.dylib`objc_destructInstance + 93
frame #5: 0x000000010b94e7c6 CoreFoundation`-[NSObject(NSObject) __dealloc_zombie] + 150
frame #6: 0x00000001087ee9df Foundation`-[NSOperation dealloc] + 89
frame #7: 0x0000000105a3dca2 MyApp`-[AFURLConnectionOperation dealloc](self=0x00007fc4d873aa20, _cmd="dealloc") + 162 at AFURLConnectionOperation.m:216
frame #8: 0x000000010af78afe libobjc.A.dylib`objc_object::sidetable_release(bool) + 232
frame #9: 0x0000000105a31dd1 MyApp`__destroy_helper_block_((null)=0x00007fc4d8b27000) + 65 at AFHTTPRequestOperation.m:0
frame #10: 0x000000010d1226b1 libsystem_blocks.dylib`_Block_release + 128
frame #11: 0x000000010d0a549b libdispatch.dylib`_dispatch_client_callout + 8
frame #12: 0x000000010d08d34b libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1738
frame #13: 0x000000010b8a63e9 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
frame #14: 0x000000010b867939 CoreFoundation`__CFRunLoopRun + 2073
frame #15: 0x000000010b866e98 CoreFoundation`CFRunLoopRunSpecific + 488
frame #16: 0x000000010dd2cad2 GraphicsServices`GSEventRunModal + 161
frame #17: 0x00000001095c9676 UIKit`UIApplicationMain + 171
frame #18: 0x0000000105767d3f MyApp`main(argc=7, argv=0x00007fff5a541620) + 111 at main.m:33
frame #19: 0x000000010d0da92d libdyld.dylib`start + 1
I set enabled Zombie Objects in my scheme and got the following error
*** -[NSMutableURLRequest release]: message sent to deallocated instance 0x7fc4d8acc460
Would any one of you have an idea what is causing the crash? Using Xcode 6 works like a charm but I'd really like to use the new Swift features in my code ...
To answer my own question and leave this here for anyone out there who might be running into the same problem:
Apparently, the Swift 2.0 compiler doesn't like closures being passed an inout parameter. I had a closure in place which could be used to further customize my request which took an object of type NSMutableURLRequest as an inout parameter. Once changing this closure to simply return the request and removing the inout everything works as expected again ...

[CFNumber retain]: message sent to deallocated instance

I am getting a EXC_BAD_ACCESS error every time I trigger a certain segue in my app. Thanks to these two links, I learned you can trouble shoot EXC_BAD_ACCESS easier after enabling NSZombies.
How do I set up NSZombieEnabled in Xcode 4?
http://www.touch-code-magazine.com/how-to-debug-exc_bad_access/
I am using this app adhoc and testing it adhoc. http://www.raywenderlich.com/13511/how-to-create-an-app-like-instagram-with-a-web-service-backend-part-12
When the app loads, a UIScrollView with pictures are shown. When you tap a picture, a push segue is triggered to the fullscreen shot of that picture. The app runs perfectly on iPad but on my iPhone 4 it crashes every time before the push segue. Ive been stuck on this for a week. I just found out what NSZombies are and how to enable them: after I enable them the dubber reads as follows:
2015-07-03 22:26:36.170 iReporter[1878:60b] *** -[CFNumber retain]: message sent to deallocated instance 0x172e6210
After learning how to input 'bt' into the debugger out put to get more info, this is what the debugger reads now;
* thread #1: tid = 0x7246e, 0x2f1e515c CoreFoundation`___forwarding___ + 540, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xdefe)
* frame #0: 0x2f1e515c CoreFoundation`___forwarding___ + 540
frame #1: 0x2f134768 CoreFoundation`_CF_forwarding_prep_0 + 24
frame #2: 0x2f11e5a8 CoreFoundation`+[__NSDictionaryM __new:::::] + 536
frame #3: 0x2f1212f0 CoreFoundation`-[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 240
frame #4: 0x2f125dcc CoreFoundation`+[NSDictionary dictionaryWithObjectsAndKeys:] + 372
frame #5: 0x000c96a4 iReporter`-[StreamPhotoScreen viewDidLoad](self=0x172e7560, _cmd=0x32053af3) + 256 at StreamPhotoScreen.m:20
frame #6: 0x31a044aa UIKit`-[UIViewController loadViewIfRequired] + 518
frame #7: 0x31a04268 UIKit`-[UIViewController view] + 24
frame #8: 0x31b9036a UIKit`-[UINavigationController _startCustomTransition:] + 634
frame #9: 0x31aadd62 UIKit`-[UINavigationController _startDeferredTransitionIfNeeded:] + 418
frame #10: 0x31aadb6c UIKit`-[UINavigationController __viewWillLayoutSubviews] + 44
frame #11: 0x31aadb04 UIKit`-[UILayoutContainerView layoutSubviews] + 184
frame #12: 0x319ffd58 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 380
frame #13: 0x3167d62a QuartzCore`-[CALayer layoutSublayers] + 142
frame #14: 0x31678e3a QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 350
frame #15: 0x31678ccc QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
frame #16: 0x316786de QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 230
frame #17: 0x316784ee QuartzCore`CA::Transaction::commit() + 314
frame #18: 0x31a033e0 UIKit`_UIApplicationHandleEventQueue + 8232
frame #19: 0x2f1ae20a CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
frame #20: 0x2f1ad6da CoreFoundation`__CFRunLoopDoSources0 + 206
frame #21: 0x2f1abece CoreFoundation`__CFRunLoopRun + 622
frame #22: 0x2f116ebe CoreFoundation`CFRunLoopRunSpecific + 522
frame #23: 0x2f116ca2 CoreFoundation`CFRunLoopRunInMode + 106
frame #24: 0x3401c662 GraphicsServices`GSEventRunModal + 138
frame #25: 0x31a6314c UIKit`UIApplicationMain + 1136
frame #26: 0x000c699c iReporter`main(argc=1, argv=0x27d44cec) + 108 at main.m:16
(lldb)
If i need to post more code/info it might be this: (section of code that the editor highlights on crash sometimes as well telling me its EXC_BAD_ACCESS_)
[api commandWithParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:#"stream", #"command", IdPhoto,#"IdPhoto", nil] onCompletion:^(NSDictionary *json) {
All I am trying to do is call the above data using j son and load it via a push segue. It works absolutely fine on iPad but crashes every time on iPhone 4?
Find the NSNumber property declaration,and check if you have wrongly give a type of assign.

Undefined key NSException in UIPickerView iOS7.1

I'm getting an exception in the iOS 7.1 simulator that doesn't appear in 7.0. It appears to be handled somewhere in the core because it only triggers an exception raise breakpoint. It doesn't log to the console or crash. This occurs while scrolling through options in a UIPickerView. There is no meaningful backtrace available (right from UIApplicationMain into objc_exception_throw), but examining the exception during throw in the debugger shows:
[<UIPickerView 0xb9a6700> valueForUndefinedKey:]: this class is not key value coding-compliant for the key _mode.
I searched in my project for mode, setMode:, mode = but I don't think I'm the one setting this. Anyone else run into this? I guess it's okay if it's not crashing the app but it gave me a scare, and I'd rather take action to prevent it from being thrown. If I have some more time I'll try to isolate this in a test project and follow up.
Edit: Better backtrace:
thread #1: tid = 0x10975c, 0x02590909 libc++abi.dylib`__cxa_throw, queue = 'com.apple.main-thread, stop reason = breakpoint 1.2
frame #0: 0x02590909 libc++abi.dylib`__cxa_throw
frame #1: 0x01b1d9fc libobjc.A.dylib`objc_exception_throw + 323
frame #2: 0x020e1fe1 CoreFoundation`-[NSException raise] + 17
frame #3: 0x017ddc7a Foundation`-[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 282
frame #4: 0x0174adfd Foundation`_NSGetUsingKeyValueGetter + 81
frame #5: 0x0174a437 Foundation`-[NSObject(NSKeyValueCoding) valueForKey:] + 260
frame #6: 0x0d615dff AccessibilityUtilities`-[NSObject(UIAccessibilitySafeCategory) safeValueForKey:] + 43
frame #7: 0x1151c1f6 UIKit`-[UIAccessibilityPickerComponent accessibilityTraits] + 398
frame #8: 0x0d716021 UIAccessibility`-[NSObject(AXPrivCategory) accessibilityAttributeValue:] + 1865
frame #9: 0x0d70a7d7 UIAccessibility`_copyMultipleAttributeValuesCallback + 409
frame #10: 0x0d76c537 AXRuntime`_AXXMIGCopyMultipleAttributeValues + 202
frame #11: 0x0d767e78 AXRuntime`_XCopyMultipleAttributeValues + 473
frame #12: 0x0d7726b4 AXRuntime`mshMIGPerform + 256
frame #13: 0x01fcdca5 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
frame #14: 0x01fcd9db CoreFoundation`__CFRunLoopDoSource1 + 523
frame #15: 0x01ff868c CoreFoundation`__CFRunLoopRun + 2156
frame #16: 0x01ff79d3 CoreFoundation`CFRunLoopRunSpecific + 467
frame #17: 0x01ff77eb CoreFoundation`CFRunLoopRunInMode + 123
frame #18: 0x03fea5ee GraphicsServices`GSEventRunModal + 192
frame #19: 0x03fea42b GraphicsServices`GSEventRun + 104
frame #20: 0x007ddf9b UIKit`UIApplicationMain + 1225
frame #21: 0x0004863d [redacted]`main(argc=1, argv=0xbfffef50) + 141 at main.m:16
In my case, on Xcode 6.2 and iOS 8.2, only simulator crashes (but can safely continue). Since _mode is nowhere within our code, it's probably safe to assume there is a simulator bug or misconfiguration.
For now, I am using a category on the offending UIPickerView to get rid of the annoyance:
#import "UIPickerView+FixCrash.h"
#implementation UIPickerView (FixCrash)
#if TARGET_IPHONE_SIMULATOR
- (id)valueForUndefinedKey:(NSString *)key
{
return nil;
}
#endif
#end

Running my application with Xcode 4.5 (iOS 6 SDK) immediately crashes my application unless I have Guard Malloc enabled

This problem is iOS Simulator only, it doesn't not happen on Device.
My application doesn't even get into the main function. It crashes somewhere in malloc:
* thread #1: tid = 0x1c03, 0x96fc1548 libsystem_c.dylib`malloc_zone_malloc + 72, stop reason = EXC_BAD_ACCESS (code=2, address=0xc)
frame #0: 0x96fc1548 libsystem_c.dylib`malloc_zone_malloc + 72
frame #1: 0x02f51a38 CoreFoundation`__CFAllocatorSystemAllocate + 24
frame #2: 0x02f51a13 CoreFoundation`CFAllocatorAllocate + 147
frame #3: 0x02f5922c CoreFoundation`__CFGetConverter + 508
frame #4: 0x02fa3dee CoreFoundation`CFStringEncodingGetConverter + 14
frame #5: 0x02f6f4ee CoreFoundation`CFStringGetSystemEncoding + 62
frame #6: 0x01b7b062 Foundation`_NSDefaultCStringEncoding + 19
frame #7: 0x02b547cf libobjc.A.dylib`_class_initialize + 305
frame #8: 0x02b5ba0d libobjc.A.dylib`prepareForMethodLookup + 158
frame #9: 0x02b52aeb libobjc.A.dylib`lookUpMethod + 81
frame #10: 0x02b52e22 libobjc.A.dylib`_class_lookupMethodAndLoadCache3 + 47
For some reason, enabled Guard Malloc makes it work just fine.
My application was working fine with the previous version of Xcode. Something about iOS 6/Xcode 4.5 caused this to arise.

Resources