Debugging in XCode: Exception Breakpoints - ios

I'm debugging a random SIGTRAP crash right now that just happens in the background. It's probably something that has to do with an NSManagedObjectContext somewhere.
Besides that, I'm trying to debug it using an exception breakpoint to at least find out where it's originating from. The only problem is that the crash/breakpoint occurs in a 0 objc_exception_throw, which is no help to me.
The data I get back looks like this:
libobjc.A.dylib`objc_exception_throw:
0x32a3a960: push {r4, r5, r6, r7, lr} // breakpoint stops here
0x32a3a962: add r7, sp, #12
0x32a3a964: mov r4, r0
0x32a3a966: movs r0, #16
0x32a3a968: blx 0x32a46854 ; symbol stub for: -[NSObject isEqual:]
So my question is, how I can I create an exception breakpoint to initiate itself earlier? I'm trying to make the breakpoint occur in the last bit of actual Objective-C code before the crash.
I have tried editing the breakpoint to be shared, break on throw, then break on catch, and have changed the type of exception between Objective-C, C++, and "all" with no luck.
How can I make the exception breakpoint throw earlier?
Unless there is a way to decipher the code I posted. If that's possible, please give me a brief explanation of what it means, and how you deciphered it so I can learn to do so as well :)
Thanks everyone!
If I let the program run...
It continues to the crash, which looks like this:
libsystem_kernel.dylib`mach_msg_trap:
0x30830ea0: mov r12, sp
0x30830ea4: push {r4, r5, r6, r8}
0x30830ea8: ldm r12, {r4, r5, r6}
0x30830eac: mvn r12, #30
0x30830eb0: svc #128
0x30830eb4: pop {r4, r5, r6, r8} // SIGTRAP throws here
0x30830eb8: bx lr
Stack trace when running command "bt" as a debugger command
* thread #13: tid = 0x2337, 0x32a3a960 libobjc.A.dylib`objc_exception_throw, stop reason = breakpoint 1.1
frame #0: 0x32a3a960 libobjc.A.dylib`objc_exception_throw
frame #1: 0x340f9fee CoreData`-[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 298
frame #2: 0x341522d2 CoreData`-[NSManagedObjectContext save:] + 730
frame #3: 0x32054b02 UIKit`__84-[UIManagedDocument writeContents:toURL:forSaveOperation:originalContentsURL:error:]_block_invoke_0 + 30
frame #4: 0x34155bc0 CoreData`developerSubmittedBlockToNSManagedObjectContextPerform + 88
frame #5: 0x36e3d4b6 libdispatch.dylib`_dispatch_client_callout + 22
frame #6: 0x36e419f6 libdispatch.dylib`_dispatch_barrier_sync_f_invoke + 30
frame #7: 0x34155d42 CoreData`-[NSManagedObjectContext performBlockAndWait:] + 174
frame #8: 0x32054862 UIKit`-[UIManagedDocument writeContents:toURL:forSaveOperation:originalContentsURL:error:] + 986
frame #9: 0x3205418a UIKit`-[UIManagedDocument writeContents:andAttributes:safelyToURL:forSaveOperation:error:] + 698
frame #10: 0x32017ce4 UIKit`__block_global_4 + 68
frame #11: 0x32017c80 UIKit`__block_global_3 + 156
frame #12: 0x339c767c Foundation`-[NSFileCoordinator _invokeAccessor:thenCompletionHandler:] + 144
frame #13: 0x339c791e Foundation`__73-[NSFileCoordinator coordinateWritingItemAtURL:options:error:byAccessor:]_block_invoke_0 + 90
frame #14: 0x339c894e Foundation`-[NSFileCoordinator(NSPrivate) _invokeAccessor:orDont:thenRelinquishAccessClaimForID:] + 202
frame #15: 0x339c926c Foundation`-[NSFileCoordinator(NSPrivate) _coordinateWritingItemAtURL:options:error:byAccessor:] + 548
frame #16: 0x339c78be Foundation`-[NSFileCoordinator coordinateWritingItemAtURL:options:error:byAccessor:] + 90
frame #17: 0x32017254 UIKit`-[UIDocument _coordinateWritingItemAtURL:error:byAccessor:] + 720
frame #18: 0x320179a0 UIKit`__59-[UIDocument saveToURL:forSaveOperation:completionHandler:]_block_invoke_0 + 284
frame #19: 0x36e3e11e libdispatch.dylib`_dispatch_call_block_and_release + 10
frame #20: 0x36e41ece libdispatch.dylib`_dispatch_queue_drain$VARIANT$mp + 142
frame #21: 0x36e41dc0 libdispatch.dylib`_dispatch_queue_invoke$VARIANT$mp + 40
frame #22: 0x36e4291c libdispatch.dylib`_dispatch_root_queue_drain + 184
frame #23: 0x36e42ac0 libdispatch.dylib`_dispatch_worker_thread2 + 84
frame #24: 0x33ba7a10 libsystem_c.dylib`_pthread_wqthread + 360
frame #25: 0x33ba78a4 libsystem_c.dylib`start_wqthread + 8
Check out the link that Matt Wilding posted in the comments of his answer!

You don't have much control over where that breakpoint triggers. Once you've hit the breakpoint though, you can use the bt command to print the current stack trace.
EDIT: With the backtrace...
It looks like UIDocument's -saveToURL:forSaveOperation:completionHandler: method is the culprit. I've never used the class before, so I can't help too much. If you're calling that method anywhere in your code (like from a block?), you could also put a breakpoint there, in anticipation of the failure.

Related

Swift malloc_error_break crashes with double free

I'm working on an app that fetches data from a web API. Most of the time, it runs perfectly; however, sometimes I'll received the error:
malloc: *** error for object 0x7fc2b061de30: double free
*** set a breakpoint in malloc_error_break to debug
I've set a malloc_error_break breakpoint, and this shows up when the app crashes, with the first line highlighted:
0x112375760 <+0>: pushq %rbp
0x112375761 <+1>: movq %rsp, %rbp
0x112375764 <+4>: nop
0x112375765 <+5>: nopl (%rax)
0x112375769 <+9>: popq %rbp
0x11237576a <+10>: retq
I have no clue what any of this means. I've searched stack exchange for hours, but I can't get any help. Once, the error showed up as:
pointer being freed was not allocated
Please don't judge me, but I don't know what a pointer is, what it means to free something, or allocate an object. If anyone wants to give me a quick crash course and/or enlighten me as what my error could be, that would be wonderful.
EDIT:
I believe the error may be coming from an UIImageView extension to download an image:
extension UIImageView {
func downloadedFrom(targetURL: NSURL, onCompletion: (UIImage?, NSError?) -> Void) {
print("downloading image")
SpotifyAPIManager.sharedInstance.auth.client.get(targetURL.absoluteString, success: { (data, response) in
print("successfully downloaded image")
guard (response as NSHTTPURLResponse).statusCode == 200 else {
print("error in http response. status code: \((response as NSHTTPURLResponse).statusCode)")
return
}
let image = UIImage(data: data)
onCompletion(image, nil)
}, failure: { error in
print("error while downloading image: \(error)")
})
}
}
(the auth.client.get is a method from the OAuthSwift framework)
I printed out the backtrace after a crash:
* thread #1: tid = 0x2cbf0, 0x00000001089aa760 libsystem_malloc.dylib`malloc_error_break, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x00000001089aa760 libsystem_malloc.dylib`malloc_error_break
frame #1: 0x00000001089a3270 libsystem_malloc.dylib`szone_error + 406
frame #2: 0x00000001089a4f07 libsystem_malloc.dylib`tiny_malloc_from_free_list + 881
frame #3: 0x00000001089a3685 libsystem_malloc.dylib`szone_malloc_should_clear + 294
frame #4: 0x00000001089ab6e6 libsystem_malloc.dylib`malloc_zone_calloc + 78
frame #5: 0x00000001089abe4f libsystem_malloc.dylib`calloc + 49
frame #6: 0x0000000109bb5ee0 ImageIO`initImageAppleJPEG + 971
frame #7: 0x0000000109bbbc9e ImageIO`_CGImagePluginInitAppleJPEG + 76
frame #8: 0x0000000109af7dff ImageIO`makeImagePlus + 1377
frame #9: 0x0000000109af7282 ImageIO`CGImageSourceCreateImageAtIndex + 184
frame #10: 0x0000000106915ef0 UIKit`_UIImageRefFromData + 423
frame #11: 0x00000001066f5086 UIKit`-[UIImage(UIImagePrivate) _initWithData:preserveScale:cache:] + 124
frame #12: 0x00000001042c7874 Spotify`#nonobjc UIImage.init(data : NSData) -> UIImage? + 36 at SongTableViewCell.swift:0
frame #13: 0x00000001042c73dc Spotify`UIImage.__allocating_init(data : NSData) -> UIImage? + 76 at SongTableViewCell.swift:0
frame #14: 0x00000001042c718b Spotify`UIImageView.(data=142201 bytes, response=0x00007fd62a64bd90, onCompletion=0x00000001042c6ab0 Spotify`partial apply forwarder for reabstraction thunk helper from #callee_unowned #convention(block) (#unowned Swift.Optional<__ObjC.UIImage>, #unowned Swift.Optional<__ObjC.NSError>) -> (#unowned ()) to #callee_owned (#owned Swift.Optional<__ObjC.UIImage>, #owned Swift.Optional<__ObjC.NSError>) -> (#unowned ()) at SongTableViewCell.swift) -> ()) -> ()).(closure #1) + 315 at SongTableViewCell.swift:65
frame #15: 0x00000001042bec63 Spotify`thunk + 35 at SpotifyAPIManager.swift:0
frame #16: 0x00000001042c6891 Spotify`partial apply for thunk + 81 at SongTableViewCell.swift:0
frame #17: 0x0000000108087f86 OAuthSwift`OAuthSwiftHTTPRequest.(data=142201 bytes, response=0x00007fd62a64bd90, error=nil, self=0x00007fd62a636411) -> ()).(closure #1).(closure #1) + 5206 at OAuthSwiftHTTPRequest.swift:149
frame #18: 0x0000000108088ae7 OAuthSwift`thunk + 103 at OAuthSwiftHTTPRequest.swift:0
frame #19: 0x0000000104bebb49 CFNetwork`__75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 19
frame #20: 0x0000000104bfe0f2 CFNetwork`__49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 302
frame #21: 0x000000010602b630 Foundation`__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
frame #22: 0x0000000105f66805 Foundation`-[NSBlockOperation main] + 101
frame #23: 0x0000000105f49725 Foundation`-[__NSOperationInternal _start:] + 646
frame #24: 0x0000000105f49336 Foundation`__NSOQSchedule_f + 194
frame #25: 0x00000001087b13eb libdispatch.dylib`_dispatch_client_callout + 8
frame #26: 0x00000001087991ef libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1738
frame #27: 0x00000001054430f9 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
frame #28: 0x0000000105404b99 CoreFoundation`__CFRunLoopRun + 2073
frame #29: 0x00000001054040f8 CoreFoundation`CFRunLoopRunSpecific + 488
frame #30: 0x0000000109fdead2 GraphicsServices`GSEventRunModal + 161
frame #31: 0x0000000106693f09 UIKit`UIApplicationMain + 171
frame #32: 0x00000001042cbe72 Spotify`main + 114 at AppDelegate.swift:14
frame #33: 0x00000001087e592d libdyld.dylib`start + 1
Once again I have no clue what this means but it could help debug.
Without any code to back up your problem it's hard to say exactly what's causing this. As a note of education: Pointers are references to memory allocated on the heap, and many different objects can point to the same memory location. Although Swift doesn't really use pointers, the underlying runtime does, and here, you've tried to access some memory location that the runtime thinks should no longer be allocated within your program's memory. As for the assembly code, that's showing you what's happening in the hardware at the time this is occurring. A brief rundown shows that the hardware is trying to move objects around in memory between the registers, and when it goes to pop to access one of the memory locations dereferenced by what's stored in the register, this is where it crashes. If you can post some code from where you think this might be happening, or from a certain part of the app where it does this frequently, maybe we can be of more help!
Edit: Also as for the actual error message itself: This means that that specific memory location has already been freed (which in this case would mean that the runtime doesn't think you have any more references to any objects that point there, and then it tries to free it again, resulting in the double-free error.
Disclaimer: I know this isn't really an answer, and would be better suited as a comment but it was too long! I wanted to educate OP!

EXC_BAD_INSTRUCTION upon pressing a button

I'm newbie in Swift and I'm currenlty trying to learn it but I faced a mystery issue. As you can see in the image below, there are some controls that are linked properly to this View Controller and upon pressing a button in the UI we execute this code below but I always got an EXC_BAD_INSTRUCTION. I don't understand why!!
Here is some info from the stack trace.
(lldb) thread info
thread #1: tid = 0x9319, 0x0006c5d5 App`App.AViewController.sendCommentViaEmail (self=<unavailable>)() -> () + 9349 at AViewController.swift:49, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
(lldb) frame select 1
frame #1: 0x037067cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84:
-> 0x37067cd: addl $0x1c, %esp
0x37067d0: popl %esi
0x37067d1: popl %edi
0x37067d2: popl %ebx
EDITED:
Stacktrace below
* thread #1: tid = 0x1e19, 0x0005a5d5 A`A.AViewController.sendCommentViaEmail (self=<unavailable>)() -> () + 9349 at AViewController.swift:49, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
* frame #0: 0x0005a5d5 A`A.AViewController.sendCommentViaEmail (self=<unavailable>)() -> () + 9349 at AViewController.swift:49
frame #1: 0x036f47cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
frame #2: 0x01ea323d UIKit`-[UIApplication sendAction:to:from:forEvent:] + 99
frame #3: 0x02213840 UIKit`-[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
frame #4: 0x036f47cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
frame #5: 0x01ea323d UIKit`-[UIApplication sendAction:to:from:forEvent:] + 99
frame #6: 0x01ea31cf UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
frame #7: 0x01fd6e86 UIKit`-[UIControl sendAction:to:forEvent:] + 69
frame #8: 0x01fd72a3 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 598
frame #9: 0x01fd650d UIKit`-[UIControl touchesEnded:withEvent:] + 660
frame #10: 0x01ef360a UIKit`-[UIWindow _sendTouchesForEvent:] + 874
frame #11: 0x01ef40e5 UIKit`-[UIWindow sendEvent:] + 791
frame #12: 0x01eb9549 UIKit`-[UIApplication sendEvent:] + 242
frame #13: 0x01ec937e UIKit`_UIApplicationHandleEventFromQueueEvent + 20690
frame #14: 0x01e9db19 UIKit`_UIApplicationHandleEventQueue + 2206
frame #15: 0x039791df CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
frame #16: 0x0396eced CoreFoundation`__CFRunLoopDoSources0 + 253
frame #17: 0x0396e248 CoreFoundation`__CFRunLoopRun + 952
frame #18: 0x0396dbcb CoreFoundation`CFRunLoopRunSpecific + 443
frame #19: 0x0396d9fb CoreFoundation`CFRunLoopRunInMode + 123
frame #20: 0x085dc24f GraphicsServices`GSEventRunModal + 192
frame #21: 0x085dc08c GraphicsServices`GSEventRun + 104
frame #22: 0x01ea18b6 UIKit`UIApplicationMain + 1526
frame #23: 0x000919cc A`main(argc=1, argv=0xbffaa62c) + 76 at main.m:12
frame #24: 0x04490ac9 libdyld.dylib`start + 1
Here are the properties I'm using:
I got the same result whether they are linked to the UI or not.
Where does emailToMyselfSwitch come from? If it's an IBOutlet it seems that you forgot to connect it from IB to your code. If that's not the case please show more context.
This error EXC_BAD_INSTRUCTION generally means that you are calling a property or method (selector?) on a null object or an object that can't respond to the selector ie self.null.on or a property that cannot be accessed because it was released.
I've had trouble in the past with these weak vars falling away. Try deleting the weak in your property.
your code is correct. The problem is not in the connection with outlet. I´ve tested and prints: "Value: nil"
The problem is in other part of code.
The message "self=" is not normal.
You can show us more information.

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

Crash that not able to get [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
thread #1: tid = 0xba03, 0x3a156b26 libobjc.A.dylib`objc_msgSend + 6, queue = 'com.apple.main-thread, stop reason = EXC_BAD_ACCESS (code=1, address=0xa000000c)
frame #0: 0x3a156b26 libobjc.A.dylib`objc_msgSend + 6
frame #1: 0x2fcfc654 CoreFoundation`CFRelease + 556
frame #2: 0x2fd07b44 CoreFoundation`-[__NSArrayM dealloc] + 156
frame #3: 0x3a166b0a libobjc.A.dylib`objc_object::sidetable_release(bool) + 174
frame #4: 0x3a158006 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 358
frame #5: 0x2fcff980 CoreFoundation`_CFAutoreleasePoolPop + 16
frame #6: 0x3253724c UIKit`_wrapRunLoopWithAutoreleasePoolHandler + 36
frame #7: 0x2fd971cc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
frame #8: 0x2fd94b70 CoreFoundation`__CFRunLoopDoObservers + 284
frame #9: 0x2fd94eb2 CoreFoundation`__CFRunLoopRun + 730
frame #10: 0x2fcffc26 CoreFoundation`CFRunLoopRunSpecific + 522
frame #11: 0x2fcffa0a CoreFoundation`CFRunLoopRunInMode + 106
frame #12: 0x349de282 GraphicsServices`GSEventRunModal + 138
frame #13: 0x325a3048 UIKit`UIApplicationMain + 1136
frame #14: 0x000ce914 test`main(argc=1, argv=0x27dadd04) + 116 at main.m:16
frame #15: 0x3a663ab6 libdyld.dylib`start + 2
I am trying to solve this crash but I am not able to get the reason for the crash as why it ios coming. Can anybody tell exactly what will be the issue as I am not getting this crash evertime.
This can just help you in sorting out where the crash is happening.
Just add a exception breakpoint so you can catch the error when it crashes.
After adding the breakpoint run the app again and test where it crashes. Almost this finds all the EXC_BAD_ACCESS crashes and puts the breakpoint in the line where the exception is caught.
The Problem could be Something like You are assigning Some text Value to Label or button in some Thread.
If Yes you can't do this. You can only assign the Value in Main thread.

-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke crash

I'm having an issue finding the source of this crash in my iOS app which has a core data model using iCloud to store user search history and user favourites. The app crashes after pressing the home button then restarting the app. I does not happen on the first use, but usually fourth or fifth time the app is started.
The backtrace is below:
* thread #1: tid = 0xea2b, 0x02e5c88a libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread, stop reason = breakpoint 1.1
frame #0: 0x02e5c88a libobjc.A.dylib`objc_exception_throw
frame #1: 0x03225903 CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:] + 275
frame #2: 0x0317890b CoreFoundation`___forwarding___ + 1019
frame #3: 0x031784ee CoreFoundation`_CF_forwarding_prep_0 + 14
frame #4: 0x011a3bf9 Foundation`__57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 40
frame #5: 0x031e4524 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
frame #6: 0x0313c00b CoreFoundation`_CFXNotificationPost + 2859
frame #7: 0x010dd951 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 98
frame #8: 0x014dacb8 UIKit`-[UIApplication _deactivateForReason:notify:] + 370
frame #9: 0x014dada6 UIKit`-[UIApplication _deactivateForReason:] + 48
frame #10: 0x014e7e14 UIKit`-[UIApplication _handleApplicationSuspend:eventInfo:] + 354
frame #11: 0x014f4a45 UIKit`-[UIApplication handleEvent:withNewEvent:] + 3904
frame #12: 0x014f4de9 UIKit`-[UIApplication sendEvent:] + 85
frame #13: 0x014e2025 UIKit`_UIApplicationHandleEvent + 736
frame #14: 0x040a62f6 GraphicsServices`_PurpleEventCallback + 776
frame #15: 0x040a5e01 GraphicsServices`PurpleEventCallback + 46
frame #16: 0x03103d65 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
frame #17: 0x03103a9b CoreFoundation`__CFRunLoopDoSource1 + 523
frame #18: 0x0312e77c CoreFoundation`__CFRunLoopRun + 2156
frame #19: 0x0312dac3 CoreFoundation`CFRunLoopRunSpecific + 467
frame #20: 0x0312d8db CoreFoundation`CFRunLoopRunInMode + 123
frame #21: 0x040a49e2 GraphicsServices`GSEventRunModal + 192
frame #22: 0x040a4809 GraphicsServices`GSEventRun + 104
frame #23: 0x014e1d3b UIKit`UIApplicationMain + 1225
frame #24: 0x0000214d MBSSearch`main(argc=1, argv=0xbfffeed8) + 141 at main.m:15
I added a symbolic breakpoint -[NSNotificationCenter addObserver:selector:name:object:] with a debugger command PO but get a ton of useless iCloud data in the debug output like this:
2013-12-25 10:06:48.338 MyApp[1543:350f] -[PFUbiquityTransactionLog loadContents:](345): CoreData: Ubiquity: Error encountered while trying to load the comparison metadata for transaction log: <PFUbiquityTransactionLog: 0xf365da0>
transactionLogLocation: <PFUbiquityLocation: 0xb62e990>: /Users/me/Library/Application Support/iPhone Simulator/7.0.3-64/Library/Mobile Documents/WS9VY4R2C6~com~me~myapp/data/me~simF624C941-DBCF-57CE-98C0-0DC98418B1E4/Appstore/~qmbb44VcI_8d7OJMA6dsq8P47PO1E4pQCb7q5bp3JA=/5E401B20-4502-4E53-9B76-415122EE8882.1.cdt
transactionNumber: (null)
Error: Error Domain=NSCocoaErrorDomain Code=134302 "The operation couldn’t be completed. (Cocoa error 134302.)" UserInfo=0xb642ca0 {reason=Error reading the log file at location: (null)
userInfo: (null)}
userInfo: {
reason = "Error reading the log file at location: (null)\nuserInfo: (null)";
Any ideas on tracing the cause of the crash?
EDIT: I've also tried looking for NSZombies using Instruments and can reproduce the crash without a zombie error
EDIT2: This link is extremely helpful: http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1
What do you mean
I added a symbolic breakpoint -[NSNotificationCenter
addObserver:selector:name:object:] with a debugger command PO
You don't use the PO command to add a symbolic breakpoint. The easiest way to add a symbolic breakpoint is using the breakpoint navigator in Xcode. You could also look up the breakpoint commands in the LLDB command line, but those are a little harder to figure out.
As for your crash, it looks like you've set up a notification center notification for suspend events. Do you add any notification manager observers? Or are you using any third party libraries? You might have a third party library that is adding a notification that you are not aware of.

Resources