summaryrefslogtreecommitdiffstats
path: root/libart
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2015-06-11 15:09:16 -0700
committerMathieu Chartier <mathieuc@google.com>2015-06-11 15:55:48 -0700
commitb9f954826c2e81667f5aa466aa3084f789c384fb (patch)
tree7ed9192c5b64fa08b904ba10f5972c2ab7ee6837 /libart
parent28889223fc7eb311775ed70335e2d3064a58b17e (diff)
downloadlibcore-b9f954826c2e81667f5aa466aa3084f789c384fb.zip
libcore-b9f954826c2e81667f5aa466aa3084f789c384fb.tar.gz
libcore-b9f954826c2e81667f5aa466aa3084f789c384fb.tar.bz2
Send SIGQUIT when finalizer times out
The motivation is to get a native stack trace of the thread if it is stuck in native code when runing a finalizer. Idea from agampe. Bug: 21060358 Change-Id: I370988e6a0067e1d407c21881c82e49b6adec050
Diffstat (limited to 'libart')
-rw-r--r--libart/src/main/java/java/lang/Daemons.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/libart/src/main/java/java/lang/Daemons.java b/libart/src/main/java/java/lang/Daemons.java
index 43066e1..a6ac449 100644
--- a/libart/src/main/java/java/lang/Daemons.java
+++ b/libart/src/main/java/java/lang/Daemons.java
@@ -16,6 +16,8 @@
package java.lang;
+import android.system.Os;
+import android.system.OsConstants;
import dalvik.system.VMRuntime;
import java.lang.ref.FinalizerReference;
import java.lang.ref.Reference;
@@ -295,6 +297,14 @@ public final class Daemons {
// We use the stack from where finalize() was running to show where it was stuck.
syntheticException.setStackTrace(FinalizerDaemon.INSTANCE.getStackTrace());
Thread.UncaughtExceptionHandler h = Thread.getDefaultUncaughtExceptionHandler();
+ // Send SIGQUIT to get native stack traces.
+ try {
+ Os.kill(Os.getpid(), OsConstants.SIGQUIT);
+ // Sleep a few seconds to let the stack traces print.
+ Thread.sleep(5000);
+ } catch (Exception e) {
+ System.logE("failed to send SIGQUIT", e);
+ }
if (h == null) {
// If we have no handler, log and exit.
System.logE(message, syntheticException);