summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2018-06-05 11:02:23 +0200
committerMartijn Coenen <maco@google.com>2018-06-05 11:18:48 +0200
commitdfa390e0802bbbdd00d7911f893cc94ec57bf159 (patch)
tree3480861ebcc12c01089de62eb395d101d4f232b1 /core/java
parentdea740bdceb20818d49a0f015c620d1d5d9e5adc (diff)
Serialize calls into BinderProxy.
The BinderProxy class is not thread-safe, hence all calls into it must be serialized. This was achieved by holding the gProxyLock in JNI code. However, a recent change added calls into BinderProxy from ActivityManagerService without holding that lock, causing ConcurrentModificationExceptions. Instead of dumping debug info from AMS, make the call directly from JNI, so we can make sure gProxyLock is held correctly. Also, only dump on debug builds. Bug: 71353150 Bug: 109701487 Test: sailfish builds, boots, info gets dumped with lowered limits. Change-Id: I446a71ce4115b9936a01a170401ef98ba3818c0b
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/Binder.java28
1 files changed, 15 insertions, 13 deletions
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index 3d76c2501440..8e8565c3574c 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -138,15 +138,6 @@ public class Binder implements IBinder {
}
/**
- * Dump proxy debug information.
- *
- * @hide
- */
- public static void dumpProxyDebugInfo() {
- BinderProxy.dumpProxyDebugInfo();
- }
-
- /**
* Check if binder transaction tracing is enabled.
*
* @hide
@@ -950,7 +941,8 @@ final class BinderProxy implements IBinder {
// about to crash.
final int totalUnclearedSize = unclearedSize();
if (totalUnclearedSize >= CRASH_AT_SIZE) {
- dumpProxyDebugInfo();
+ dumpProxyInterfaceCounts();
+ dumpPerUidProxyCounts();
Runtime.getRuntime().gc();
throw new AssertionError("Binder ProxyMap has too many entries: "
+ totalSize + " (total), " + totalUnclearedSize + " (uncleared), "
@@ -1035,11 +1027,21 @@ final class BinderProxy implements IBinder {
private static ProxyMap sProxyMap = new ProxyMap();
/**
+ * Dump proxy debug information.
+ *
+ * Note: this method is not thread-safe; callers must serialize with other
+ * accesses to sProxyMap, in particular {@link #getInstance(long, long)}.
+ *
* @hide
*/
- public static void dumpProxyDebugInfo() {
- sProxyMap.dumpProxyInterfaceCounts();
- sProxyMap.dumpPerUidProxyCounts();
+ private static void dumpProxyDebugInfo() {
+ if (Build.IS_DEBUGGABLE) {
+ sProxyMap.dumpProxyInterfaceCounts();
+ // Note that we don't call dumpPerUidProxyCounts(); this is because this
+ // method may be called as part of the uid limit being hit, and calling
+ // back into the UID tracking code would cause us to try to acquire a mutex
+ // that is held during that callback.
+ }
}
/**