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

26.7k views Asked by At

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.

3

There are 3 answers

0
plluke On

It's been answered here: objc_msgSend [__NSArrayM dealloc] crash report sometimes from Crashlytics

Basically, upgrade your Crashlytics framework to past 3.0.9. The crash was in the crash reporting framework itself.

0
some_id On

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.

1
Supanat Techasothon On

Some of logic code need to be run in background. You need to try debug where is code is error and then add this code

DispatchQueue.main.async(execute: {
     // your code
})