How to track down crashes with a stack that doesn't touch your code

So I've got one crash that comes up more often than any other crash but still very sporadically and I've never been able to reproduce it myself. The stack trace I get gives me no clues as to what has gone wrong. What I really want to know is how to go about tracking something like this down. Normally I at least know where the code crashed and I can start investigating from there, in this case all I know is the error type. I understand that there's a memory problem somewhere but how do I know where to start looking?

Here's the information I get from HockeyApp

Reason: objc_msgSend() selector name: performSelector:withObject:withObject:
Exception Type: SIGSEGV 
Exception Codes: SEGV_ACCERR at 0x514fd0f6

1	libobjc.A.dylib	objc_msgSend + 6
2	UIKit	-[UIApplication sendAction:to:from:forEvent:] + 88
3	UIKit	-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 36
4	UIKit	-[UIControl sendAction:to:forEvent:] + 44
5	UIKit	-[UIControl _sendActionsForEvents:withEvent:] + 372
6	UIKit	-[UIControl touchesEnded:withEvent:] + 592
7	UIKit	_UIGestureRecognizerUpdate + 5526
8	UIKit	-[UIWindow _sendGesturesForEvent:] + 770
9	UIKit	-[UIWindow sendEvent:] + 664
10	UIKit	-[UIApplication sendEvent:] + 194
11	UIKit	_UIApplicationHandleEventQueue + 7118
12	CoreFoundation	__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
13	CoreFoundation	__CFRunLoopDoSources0 + 204
14	CoreFoundation	__CFRunLoopRun + 628
15	CoreFoundation	CFRunLoopRunSpecific + 522
16	CoreFoundation	CFRunLoopRunInMode + 104
17	GraphicsServices	GSEventRunModal + 136
18	UIKit	UIApplicationMain + 1134
19	life	main (main.m:10)
20	libdyld.dylib	start + 0

Edit: Formatting

Posted Feb 5, 2015, 2:26 AM UTC

12
quellish•

In this case a gesture recognizer is trying to send an action whose receiver is no longer valid. Perhaps the recognizer was not removed before the object was deallocated, etc. It may be your code that is using the recognizer or maybe not - but this is something you (should) be able to track down with Instruments. If you're experienced with Instruments you can even track it down without stimulating the crash initially. Look for views and controls with suspicious lifetimes.

2
askoruliOP•

Worked out that it was caused by a UINavigationController pop (which was accidentally left from some older code) followed by a direct set of the UINavigationController viewControllers property. On iOS 7 this left a deallocated view on top of the stack which crashed when anything happened to it.

Thanks for the help.

1