Don't reuse StringBuilder outside of lock when dumping ANR.
The ANR dumping code was reusing the shared StringBuilder while
not holding the ActivityManagerService lock. As a result, other
threads could sweep in and clobber the ANR information.
We don't want to hold the lock here, so just create a new StringBuilder.
Change-Id: I0d91af55f5c123102cfab2cd97035491efed59c0
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 80e59cd..42c42c9 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -3181,7 +3181,7 @@
}
// Log the ANR to the main log.
- StringBuilder info = mStringBuilder;
+ StringBuilder info = new StringBuilder();
info.setLength(0);
info.append("ANR in ").append(app.processName);
if (activity != null && activity.shortComponentName != null) {