From 049ebe93f4b8f2b0b9990ebc484e63a8ae03b1a6 Mon Sep 17 00:00:00 2001 From: qinyige1 Date: Mon, 20 Feb 2023 14:20:27 +0800 Subject: [PATCH] [AMS][Bugfix] Fix hang when dumping local cache info. TransferPipe exploits pipe for IPC. However, it can't be used for local dump. If data is large enough, writing will get stuck when buffer is full since reading can't be executed. So directly dump to target fd instead of using pipe for local dump. Bug: 270277093 Test: Manual Change-Id: Ic2f52672fbf9f1797dbafcd71d363be93b3b5f1e --- .../java/com/android/server/am/ActivityManagerService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 80ba683043d2e..1c742ec5d5c02 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -10763,6 +10763,13 @@ public class ActivityManagerService extends IActivityManager.Stub pw.println("\n\n** Cache info for pid " + pid + " [" + r.processName + "] **"); pw.flush(); try { + if (pid == Process.myPid()) { + // Directly dump to target fd for local dump to avoid hang. + try (ParcelFileDescriptor pfd = ParcelFileDescriptor.fromFd(fd.getInt$())) { + thread.dumpCacheInfo(pfd, args); + } + continue; + } TransferPipe tp = new TransferPipe(); try { thread.dumpCacheInfo(tp.getWriteFd(), args);