Skip to content

Commit ede8b42

Browse files
Sudheer Shankaandi34
authored andcommitted
DO NOT MERGE: Fix deadlock in AcitivityManagerService.
Don't hold mPidsSelfLocked lock when calling cleanUpApplicationRecordLocked. Bug: 31463143 Change-Id: I1fddd06f5e35b67fea041741f5746c57a39208ba (cherry picked from commit dce4be6)
1 parent a7e8c2e commit ede8b42

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,16 +2818,19 @@ private final void startProcessLocked(ProcessRecord app,
28182818
app.setPid(startResult.pid);
28192819
app.usingWrapper = startResult.usingWrapper;
28202820
app.removed = false;
2821+
ProcessRecord oldApp;
2822+
synchronized (mPidsSelfLocked) {
2823+
oldApp = mPidsSelfLocked.get(startResult.pid);
2824+
}
2825+
// If there is already an app occupying that pid that hasn't been cleaned up
2826+
if (oldApp != null && !app.isolated) {
2827+
// Clean up anything relating to this pid first
2828+
Slog.w(TAG, "Reusing pid " + startResult.pid
2829+
+ " while app is still mapped to it");
2830+
cleanUpApplicationRecordLocked(oldApp, false, false, -1,
2831+
true /*replacingPid*/);
2832+
}
28212833
synchronized (mPidsSelfLocked) {
2822-
ProcessRecord oldApp;
2823-
// If there is already an app occupying that pid that hasn't been cleaned up
2824-
if ((oldApp = mPidsSelfLocked.get(startResult.pid)) != null && !app.isolated) {
2825-
// Clean up anything relating to this pid first
2826-
Slog.w(TAG, "Reusing pid " + startResult.pid
2827-
+ " while app is still mapped to it");
2828-
cleanUpApplicationRecordLocked(oldApp, false, false, -1,
2829-
true /*replacingPid*/);
2830-
}
28312834
this.mPidsSelfLocked.put(startResult.pid, app);
28322835
Message msg = mHandler.obtainMessage(PROC_START_TIMEOUT_MSG);
28332836
msg.obj = app;

0 commit comments

Comments
 (0)