summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/os/StrictMode.java23
-rw-r--r--core/java/android/util/Slog.java20
2 files changed, 39 insertions, 4 deletions
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index 0e561bd..0ee8d86f 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -1725,10 +1725,25 @@ public final class StrictMode {
for (int i = 0; i < numViolations; ++i) {
if (LOG_V) Log.d(TAG, "strict mode violation stacks read from binder call. i=" + i);
ViolationInfo info = new ViolationInfo(p, !currentlyGathering);
- if (info.crashInfo.stackTrace.length() > 5000) {
- RuntimeException here = new RuntimeException("here");
- here.fillInStackTrace();
- Slog.w(TAG, "Stack is getting large: " + info.crashInfo.stackTrace, here);
+ if (info.crashInfo.stackTrace.length() > 10000) {
+ // 10000 characters is way too large for this to be any sane kind of
+ // strict mode collection of stacks. We've had a problem where we leave
+ // strict mode violations associated with the thread, and it keeps tacking
+ // more and more stacks on to the violations. Looks like we're in this casse,
+ // so we'll report it and bail on all of the current strict mode violations
+ // we currently are maintaining for this thread.
+ // First, drain the remaining violations from the parcel.
+ while (i < numViolations) {
+ info = new ViolationInfo(p, !currentlyGathering);
+ i++;
+ }
+ // Next clear out all gathered violations.
+ clearGatheredViolations();
+ // Now report the problem.
+ Slog.wtfStack(TAG, "Stack is too large: numViolations=" + numViolations
+ + " policy=#" + Integer.toHexString(policyMask)
+ + " front=" + info.crashInfo.stackTrace.substring(256));
+ return;
}
info.crashInfo.stackTrace += "# via Binder call with stack:\n" + ourStack;
BlockGuard.Policy policy = BlockGuard.getThreadPolicy();
diff --git a/core/java/android/util/Slog.java b/core/java/android/util/Slog.java
index 7a5fd50..e92b846 100644
--- a/core/java/android/util/Slog.java
+++ b/core/java/android/util/Slog.java
@@ -73,18 +73,38 @@ public final class Slog {
msg + '\n' + Log.getStackTraceString(tr));
}
+ /**
+ * Like {@link Log#wtf(String, String)}, but will never cause the caller to crash, and
+ * will always be handled asynchronously. Primarily for use by coding running within
+ * the system process.
+ */
public static int wtf(String tag, String msg) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, false, true);
}
+ /**
+ * Like {@link Log#wtfStack(String, String)}, but will never cause the caller to crash, and
+ * will always be handled asynchronously. Primarily for use by coding running within
+ * the system process.
+ */
public static int wtfStack(String tag, String msg) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, true, true);
}
+ /**
+ * Like {@link Log#wtf(String, Throwable)}, but will never cause the caller to crash,
+ * and will always be handled asynchronously. Primarily for use by coding running within
+ * the system process.
+ */
public static int wtf(String tag, Throwable tr) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, tr.getMessage(), tr, false, true);
}
+ /**
+ * Like {@link Log#wtf(String, String, Throwable)}, but will never cause the caller to crash,
+ * and will always be handled asynchronously. Primarily for use by coding running within
+ * the system process.
+ */
public static int wtf(String tag, String msg, Throwable tr) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, tr, false, true);
}