Search code examples
ios8objc-message-send

iOS 8 crash - objc_msgSend() selector name: respondsToSelector:


I have the following crash report. It only happens on iOS 8. I know exactly how to reproduce it but cannot for the life of me figure out where the problem is in my code. When I use a breakpoint and try to step through the app, the crash doesn't happen. How can I find where the issue is in my app?

Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0x10
Crashed Thread:  0

    Application Specific Information:
objc_msgSend() selector name: respondsToSelector:

Thread 0 Crashed:
0   libobjc.A.dylib                      0x00000001974b3bd0 objc_msgSend + 16
1   UIKit                                0x000000018ab960f4 -[UIToolbar _didMoveFromWindow:toWindow:] + 108
2   UIKit                                0x000000018aa30d44 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 700
3   UIKit                                0x000000018aa30d44 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 700
4   UIKit                                0x000000018aa30d44 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 700
5   UIKit                                0x000000018aa303dc __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 140
6   UIKit                                0x000000018aa302bc -[UIView(Hierarchy) _postMovedFromSuperview:] + 480
7   UIKit                                0x000000018aa3c0b0 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1788
8   UIKit                                0x000000018ac1c368 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke + 1432
9   UIKit                                0x000000018aa42b6c +[UIView(Animation) performWithoutAnimation:] + 84
10  UIKit                                0x000000018ac1bb2c -[_UINavigationParallaxTransition animateTransition:] + 852
11  UIKit                                0x000000018abd7b70 -[UINavigationController _startCustomTransition:] + 3032
12  UIKit                                0x000000018aae9ef0 -[UINavigationController _startDeferredTransitionIfNeeded:] + 464
13  UIKit                                0x000000018aae9cbc -[UINavigationController __viewWillLayoutSubviews] + 52
14  UIKit                                0x000000018aae9c3c -[UILayoutContainerView layoutSubviews] + 196
15  UIKit                                0x000000018aa31760 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 576
16  QuartzCore                           0x000000018a379e1c -[CALayer layoutSublayers] + 148
17  QuartzCore                           0x000000018a374884 CA::Layer::layout_if_needed(CA::Transaction*) + 316
18  QuartzCore                           0x000000018a374728 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 28
19  QuartzCore                           0x000000018a373ebc CA::Context::commit_transaction(CA::Transaction*) + 272
20  QuartzCore                           0x000000018a373c3c CA::Transaction::commit() + 524
21  QuartzCore                           0x000000018a36d364 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 76
22  CoreFoundation                       0x0000000185fac2a4 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28
23  CoreFoundation                       0x0000000185fa9230 __CFRunLoopDoObservers + 356
24  CoreFoundation                       0x0000000185fa9610 __CFRunLoopRun + 832
25  CoreFoundation                       0x0000000185ed52d4 CFRunLoopRunSpecific + 392
26  GraphicsServices                     0x000000018f59b6fc GSEventRunModal + 164
27  UIKit                                0x000000018aa9afac UIApplicationMain + 1484
28  MyAppName                            0x00000001001b8ae0 main (main.m:16)
29  libdyld.dylib                        0x0000000197b1ea08 start + 0

Solution

  • I know exactly how to reproduce it

    That alone is worth its weight in gold.

    This is a memory management issue. You will need to replicate the conditions of the crash with Zombies turned on. Some object has vanished out from under its pointer, and Zombies will tell you what object it is.

    Keep in mind that the moment of the crash probably has nothing to do with the cause of the issue. The moment of the crash is diagnostic only. The object that has vanished, probably vanished long before; it is only now, though, that someone is trying to send a message to it, only to find that it is no longer home.

    (For example, a Cocoa class that takes a delegate and whose delegate has been destroyed would cause this kind of issue. The delegate is not retained, so the Cocoa class doesn't know anything has happened. The solution would be then that you would need to set the delegate to nil before that delegate goes out of existence. I'm not saying that's the specific issue; I'm just giving an example of how this kind of thing happens.)