Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eebac6d6 authored by Martijn Coenen's avatar Martijn Coenen
Browse files

Dump proxy debug info when exceeding proxy limit.

If a process gets killed because it sends too many proxies,
dump proxy debug info so we can see what types of interfaces
it sends.

Bug: 71353150
Test: builds, output generated
Change-Id: I3a7787cb3fa73b0b4ad223b18cd79f44e22b9ef5
parent f354ba18
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -137,6 +137,15 @@ public class Binder implements IBinder {
        sTracingEnabled = false;
    }

    /**
     * Dump proxy debug information.
     *
     * @hide
     */
    public static void dumpProxyDebugInfo() {
        BinderProxy.dumpProxyDebugInfo();
    }

    /**
     * Check if binder transaction tracing is enabled.
     *
@@ -941,8 +950,7 @@ final class BinderProxy implements IBinder {
                    // about to crash.
                    final int totalUnclearedSize = unclearedSize();
                    if (totalUnclearedSize >= CRASH_AT_SIZE) {
                        dumpProxyInterfaceCounts();
                        dumpPerUidProxyCounts();
                        dumpProxyDebugInfo();
                        Runtime.getRuntime().gc();
                        throw new AssertionError("Binder ProxyMap has too many entries: "
                                + totalSize + " (total), " + totalUnclearedSize + " (uncleared), "
@@ -1026,6 +1034,14 @@ final class BinderProxy implements IBinder {

    private static ProxyMap sProxyMap = new ProxyMap();

    /**
      * @hide
      */
    public static void dumpProxyDebugInfo() {
        sProxyMap.dumpProxyInterfaceCounts();
        sProxyMap.dumpPerUidProxyCounts();
    }

    /**
     * Return a BinderProxy for IBinder.
     * This method is thread-hostile!  The (native) caller serializes getInstance() calls using
+1 −0
Original line number Diff line number Diff line
@@ -15304,6 +15304,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        public void onLimitReached(int uid) {
                            Slog.wtf(TAG, "Uid " + uid + " sent too many Binders to uid "
                                    + Process.myUid());
                            Binder.dumpProxyDebugInfo();
                            if (uid == Process.SYSTEM_UID) {
                                Slog.i(TAG, "Skipping kill (uid is SYSTEM)");
                            } else {