Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android app crashes with SIGABRT Signal 6 only while Eclipse debugging

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?

like image 896
zyamys Avatar asked Feb 06 '14 06:02

zyamys


People also ask

What is fatal signal 6 SIGABRT?

Fatal signal 6 SIGABRT it might means that your device hang at some point. Lost connection to device.

What is SIGABRT signal?

Signal 5 ( SIGTRAP ) = “General crash” Signal 6 ( SIGABRT ) = SIGABRT is commonly used by libc and other libraries to abort the program in case of critical errors. For example, glibc sends an SIGABRT in case of a detected double-free or other heap corruptions.

What sends SIGABRT?

The SIGABRT signal is sent to a process to tell it to abort, i.e. to terminate. The signal is usually initiated by the process itself when it calls abort function of the C Standard Library, but it can be sent to the process from outside like any other signal.


3 Answers

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

like image 86
Aditya P Avatar answered Nov 05 '22 09:11

Aditya P


This started happening to me in android 7.1.1

When attaching debugger my app always crashed, same when starting app in debug mode.

What fixed it for me is simply:

  • Run your app
  • Click on "Mute Breakpoints" in Debug
  • Attach the debugger
  • Re-Click on "Mute Breakpoints" to unmute
  • Done, debugging works again
like image 21
sam Avatar answered Nov 05 '22 11:11

sam


I had similar issues, but what Sam suggested didn't help - I had to actually REMOVE the breakpoints and then it worked for me.

like image 20
DustinB Avatar answered Nov 05 '22 09:11

DustinB