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

0

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

ios
objective-c
nsnotificationcenter
asked on Stack Overflow Dec 25, 2013 by Phil S • edited Dec 27, 2013 by Phil S

1 Answer

0

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.

answered on Stack Overflow Dec 25, 2013 by Duncan C

User contributions licensed under CC BY-SA 3.0