From 8d05172112436a81bed6e4a0810f8914509d8a4d Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 1 Oct 2014 14:59:58 -0700 Subject: More work on issue #17656716: Unhandled exception in Window Manager Fix Slog.wtf to not acquire the activity manager lock in its code path, so that it can never deadlock. This was the original intention of it, but part was missed. Now we can put back in the code to detect when strict mode data is getting large (a little more targeted now to the actual problem), and use Slog.wtf to report it. And as a bonus, when this happens we will now clear all of the collected violations, to avoid getting in to the bad case where IPCs start failing. So this should be good enough for L to fix the problem, with wtf reports for us to see if the underlying issue is still happening. Finally, switch a butch of stuff in the system process from Log.wtf to Slog.wtf, since many of those are deadlocks waiting to happen. Oh and fix a crash in the settings provider I noticed in APR. Change-Id: I307d51b7a4db238fd1e5fe2f3f9bf1b9c6f1c041 --- core/java/android/os/StrictMode.java | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'core/java/android/os/StrictMode.java') 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(); -- cgit v1.1