Handling race condition when dumping heaps.
1. The IPC to ActivityThread.dumpHeap() dups the input file descriptor but closes it when the IPC returns. Since the heap dump is generated asynchronously, a race condition ensues between the returning close and the dump being generated. For the intra-system-process call, the race is with ActivityManagerService closing the created file descriptor. Duping the file descriptor on the ActivityThread side should deal with this. 2. For some reason, the file descriptor wasn't closed for native heap dumps. Closing the fd in those cases as well. 3. Catch the RuntimeException from Debug.dumpHprofData in case anything else was missed. Bug: 133424499 Test: adb shell am dumpheap com.android.systemui Test: adb shell am dumpheap system Test: Use the "Capture System Heap Dump" option in Developer Settings Change-Id: I44817161533359766250de04e35902587ea9cc40
Loading
Please register or sign in to comment