Android app crashes with SIGABRT Signal 6 only while Eclipse debugging

zyamys picture zyamys · Feb 6, 2014 · Viewed 35.3k times · Source

I have an app that runs perfectly fine on a device without a debugger attached. However, I have a problem when debugging in Eclipse:

When the main thread is suspended for about 10 seconds or more (for example after hitting a breakpoint), the main thread throws a SIGABRT, apparently coming from libc.

The only explanation I could think of is that the message queue on the main thread, when not being polled, is overflowing with messages coming from another thread. However, I don't see the heap growing when the main thread is suspended. Moreover, while my app has about 20 threads between all services, content providers, broadcast receivers, http and map worker threads, etc., I can't really think of a source of any excessive messages.

So my question is: How do I fix this problem? What tools can I use and how do I go about finding what is causing my app to crash while sitting suspended in the debugger?

Edit 1:

The only thing in logcat is:

02-05 22:23:54.861: I/dalvikvm(26795): threadid=3: reacting to signal 3
02-05 22:23:54.901: D/dalvikvm(26795): threadid=1: still suspended after undo (sc=1 dc=1)
02-05 22:23:54.901: I/dalvikvm(26795): Wrote stack traces to '/data/anr/traces.txt'
02-05 22:23:58.905: A/libc(26795): Fatal signal 6 (SIGABRT) at 0x000002f5 (code=0), thread 26795 (om.myapp)

Edit 2:

Further investigation leads me to believe it is android intentionally killing my process because it mistakenly thinks the UI thread is hung. The problem is NOT in my app. So now my question is: How do I stop Android from killing my process while debugging?

Answer

Aditya P picture Aditya P · Jun 29, 2014

android intentionally kills the process because it thinks the UI thread is hung, so its a ANR right. for debugging purposes you can,

Go to Settings -> Developer options and check Show all ANRs.

This will show an App Not Responding dialog for apps running in the background. You can click the Wait button in the dialog to prevent the system from killing your process until the debugger attaches. Note that the dialog is opened automatically for apps running in the foreground. For background apps, you have to enable this option