为什么android logcat不显示运行时异常的堆栈跟踪?

时间:2021-07-06 20:57:27

An android application that I am currently developing was crashing (fixed that), due to what should have raised an IndexOutOfBoundsException. I was accessing a string in the doInBackground method of a class that extends AyncTask, from the variable arguments parameter (ie String...). I was accidentally accessing index 1 (not 0) of a one element variable argument string (mildly embarrassing...). When the application first crashed I looked at my logcat, (and many times again to confirm that I wasn't insane) and there was no stack trace for a RuntimeException to be found. I crash my phone quite often and there is always a nice little stack trace for me to look at and fix with, but I was puzzled by this. Here is the pertinent section of my logcat (which contains no stack trace for a runtimeexception), following a debug statement right before the line of code that was causing the crash:

我目前正在开发的一个android应用程序出现了崩溃(修正了这个问题),原因是我应该使用IndexOutOfBoundsException异常。我正在访问一个类的doInBackground方法中的字符串,该方法从变量参数参数(ie string…)扩展AyncTask。我不小心访问了一个单元素变量参数字符串的索引1(不是0)(有点尴尬…)当应用程序第一次崩溃时,我查看了我的logcat(并多次确认我没有发疯),并且没有找到运行时异常的堆栈跟踪。我经常崩溃我的手机,总是有一个很好的堆栈跟踪供我查看和修复,但我对此感到困惑。下面是我的logcat(它不包含runtimeexception的堆栈跟踪)的相关部分,它遵循了导致崩溃的代码行之前的调试语句:

W/dalvikvm(25643): threadid=11: thread exiting with uncaught exception (group=0x40c281f8)
D/dalvikvm(25643): GC_CONCURRENT freed 1249K, 25% free 12433K/16455K, paused 2ms+6ms
W/dalvikvm(25643): threadid=15: thread exiting with uncaught exception (group=0x40c281f8)
I/Process (25643): Sending signal. PID: 25643 SIG: 9
I/ActivityManager( 5905): Process com.trade.nav.ges (pid 25643) has died.
W/ActivityManager( 5905): Force removing r: app died, no saved state
I/WindowManager( 5905): WIN DEATH: win
I/WindowManager( 5905): WIN DEATH: win
I/SurfaceFlinger( 1746): id=3848 Removed idx=2 Map Size=4
I/SurfaceFlinger( 1746): id=3848 Removed idx=-2 Map Size=4
I/WindowManager( 5905): WIN DEATH: win
I/power   ( 5905): *** acquire_dvfs_lock : lockType : 1  freq : 1000000 
D/PowerManagerService( 5905): acquireDVFSLockLocked : type : DVFS_MIN_LIMIT  frequency :  1000000  uid : 1000  pid : 5905  tag : ActivityManager
W/ActivityManager( 5905): mDVFSLock.acquire()

And after that, another activity starts. For reference, here is the code that caused the crash:

然后,另一个活动开始了。为了便于参考,下面是导致崩溃的代码:

private class LoadImage extends AsyncTask<String, Integer, Bitmap> {
    String url = "";
    //...
    public LoadImage(ImageView iv, Context c) {
        //...
    }

    protected Bitmap doInBackground(String... urls) {
        // urls has one element
        url = urls[1];
        //...
    }
    //...
}

Any insight into what is happening would please me greatly, as I am curious about having never seen anything like this on the internet. Thanks.

任何对正在发生的事情的洞察都会让我非常高兴,因为我很好奇在网上从来没有见过这样的事情。谢谢。

Edit: I have no filter set

编辑:我没有过滤设置

2 个解决方案

#1


10  

Your threads are clearly crashing (note the thread exiting with uncaught exception on two different threads in the same process). The process is cleaning up after itself -- Sending signal indicates the process is sending a fatal signal to itself. So the question is why you aren't seeing a stack dump between these two.

您的线程显然是崩溃的(注意在同一进程中,在两个不同线程中未捕获异常的线程正在退出)。这个过程本身就在清理——发送信号表明这个过程正在向自己发送一个致命的信号。所以问题是为什么你没有看到堆栈转储在这两者之间。

The stack dump comes from RuntimeInit$UncaughtHandler, which is the framework-provided global uncaught exception handler. The process self-annihilation happens in the finally block. It's hard to see a way to get out of this without logging "FATAL EXCEPTION", unless something in Slog.e fails and throws.

堆栈转储来自RuntimeInit$UncaughtHandler,它是框架提供的全局未捕获异常处理程序。过程的自我毁灭发生在最后一个街区。如果不记录“致命异常”,就很难找到摆脱这种情况的方法,除非是在Slog中出现了一些异常。失败,抛出。

I would guess that either something is failing in Slog.e, or somebody has replaced the framework's uncaught exception handler. The latter could happen if you've incorporated some external library into your app, such as a crash log catcher or an ad network, and the new handler doesn't log the exception but does kill the process.

我猜在Slog中有一个问题。e,或者有人替换了框架的未捕获异常处理程序。如果您将一些外部库合并到应用程序中,例如一个崩溃日志捕获程序或一个广告网络,并且新的处理程序不会记录异常,但是会杀死进程。

You can track it down by attaching a Java-language debugger (e.g. Eclipse). By default it will stop on uncaught exceptions. From there you can trace it around, set breakpoints and single-step through the uncaught exception handler (if you have full sources), and so on.

您可以通过附加一个java语言调试器(例如Eclipse)来跟踪它。默认情况下,它将停止在未捕获的异常上。从那里您可以跟踪它,设置断点和单步通过未捕获的异常处理程序(如果您有完整的源代码),等等。

#2


6  

As per fadden's suspect that external library could override uncaught exception handler, I started to investigate any possible libs. Turned out that GoogleAnalytics throttles crashes and prevents the stack trace from being displayed in logcat if you turn on enableExceptionReporting. I remove this line of code then everything gets back on track!! That could be the first time I was so happy to see crashes!!

正如fadden怀疑外部库可以覆盖未捕获的异常处理程序一样,我开始研究任何可能的libs。结果显示,google分析会崩溃,如果你打开enableExceptionReporting,它会阻止堆栈跟踪显示在logcat中。我删除了这一行代码,然后一切都回到正轨!!那可能是我第一次如此高兴地看到崩溃!

#1


10  

Your threads are clearly crashing (note the thread exiting with uncaught exception on two different threads in the same process). The process is cleaning up after itself -- Sending signal indicates the process is sending a fatal signal to itself. So the question is why you aren't seeing a stack dump between these two.

您的线程显然是崩溃的(注意在同一进程中,在两个不同线程中未捕获异常的线程正在退出)。这个过程本身就在清理——发送信号表明这个过程正在向自己发送一个致命的信号。所以问题是为什么你没有看到堆栈转储在这两者之间。

The stack dump comes from RuntimeInit$UncaughtHandler, which is the framework-provided global uncaught exception handler. The process self-annihilation happens in the finally block. It's hard to see a way to get out of this without logging "FATAL EXCEPTION", unless something in Slog.e fails and throws.

堆栈转储来自RuntimeInit$UncaughtHandler,它是框架提供的全局未捕获异常处理程序。过程的自我毁灭发生在最后一个街区。如果不记录“致命异常”,就很难找到摆脱这种情况的方法,除非是在Slog中出现了一些异常。失败,抛出。

I would guess that either something is failing in Slog.e, or somebody has replaced the framework's uncaught exception handler. The latter could happen if you've incorporated some external library into your app, such as a crash log catcher or an ad network, and the new handler doesn't log the exception but does kill the process.

我猜在Slog中有一个问题。e,或者有人替换了框架的未捕获异常处理程序。如果您将一些外部库合并到应用程序中,例如一个崩溃日志捕获程序或一个广告网络,并且新的处理程序不会记录异常,但是会杀死进程。

You can track it down by attaching a Java-language debugger (e.g. Eclipse). By default it will stop on uncaught exceptions. From there you can trace it around, set breakpoints and single-step through the uncaught exception handler (if you have full sources), and so on.

您可以通过附加一个java语言调试器(例如Eclipse)来跟踪它。默认情况下,它将停止在未捕获的异常上。从那里您可以跟踪它,设置断点和单步通过未捕获的异常处理程序(如果您有完整的源代码),等等。

#2


6  

As per fadden's suspect that external library could override uncaught exception handler, I started to investigate any possible libs. Turned out that GoogleAnalytics throttles crashes and prevents the stack trace from being displayed in logcat if you turn on enableExceptionReporting. I remove this line of code then everything gets back on track!! That could be the first time I was so happy to see crashes!!

正如fadden怀疑外部库可以覆盖未捕获的异常处理程序一样,我开始研究任何可能的libs。结果显示,google分析会崩溃,如果你打开enableExceptionReporting,它会阻止堆栈跟踪显示在logcat中。我删除了这一行代码,然后一切都回到正轨!!那可能是我第一次如此高兴地看到崩溃!