How to find root cause Crashed: com.apple.main-thread in production app?

Arnie Schwarzvogel picture Arnie Schwarzvogel · Jun 15, 2015 · Viewed 15.4k times · Source

i have such a report from Crashlytics:

Thread : Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x000000019503fbd0 objc_msgSend + 16
1  CoreFoundation                 0x00000001836e5458 CFRelease + 524
2  CoreFoundation                 0x00000001836f1a18 -[__NSArrayM dealloc] + 152
3  libobjc.A.dylib                0x0000000195045724 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 564
4  CoreFoundation                 0x00000001836e9074 _CFAutoreleasePoolPop + 28
5  Foundation                     0x000000018461a588 -[NSAutoreleasePool release] + 148
6  UIKit                          0x00000001882b4460 -[UIApplication _run] + 588
7  UIKit                          0x00000001882aefac UIApplicationMain + 1488

Is there anything I can do to catch such an issue? It happens on customer devices so I have no chance to reproduce it.

Answer

system picture system · Aug 8, 2015

For crashes like this one, if the crash is reproducible, turn on NSZombies in your project's environment variables. This will keep deallocated objects alive (zombies) and when one of them is messaged, the caller and message will be captured on the crashing object.

Turn it off when done as it can block the memory of the app due to the objects not being released for zombie tracking.