Skip to content

Commit 115baf8

Browse files
Sudheer Shankagitbuildkicker
authored andcommitted
DO NOT MERGE: Fix deadlock in AcitivityManagerService.
Don't hold mPidsSelfLocked lock when calling cleanUpApplicationRecordLocked. Bug: 31463143 Change-Id: I421962cbfd7c466662edcef805c3e27321dc5a98 (cherry picked from commit b59e736)
1 parent 77fa5d9 commit 115baf8

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3424,16 +3424,19 @@ private final void startProcessLocked(ProcessRecord app, String hostingType,
34243424
app.killed = false;
34253425
app.killedByAm = false;
34263426
checkTime(startTime, "startProcess: starting to update pids map");
3427+
ProcessRecord oldApp;
3428+
synchronized (mPidsSelfLocked) {
3429+
oldApp = mPidsSelfLocked.get(startResult.pid);
3430+
}
3431+
// If there is already an app occupying that pid that hasn't been cleaned up
3432+
if (oldApp != null && !app.isolated) {
3433+
// Clean up anything relating to this pid first
3434+
Slog.w(TAG, "Reusing pid " + startResult.pid
3435+
+ " while app is still mapped to it");
3436+
cleanUpApplicationRecordLocked(oldApp, false, false, -1,
3437+
true /*replacingPid*/);
3438+
}
34273439
synchronized (mPidsSelfLocked) {
3428-
ProcessRecord oldApp;
3429-
// If there is already an app occupying that pid that hasn't been cleaned up
3430-
if ((oldApp = mPidsSelfLocked.get(startResult.pid)) != null && !app.isolated) {
3431-
// Clean up anything relating to this pid first
3432-
Slog.w(TAG, "Reusing pid " + startResult.pid
3433-
+ " while app is still mapped to it");
3434-
cleanUpApplicationRecordLocked(oldApp, false, false, -1,
3435-
true /*replacingPid*/);
3436-
}
34373440
this.mPidsSelfLocked.put(startResult.pid, app);
34383441
if (isActivityProcess) {
34393442
Message msg = mHandler.obtainMessage(PROC_START_TIMEOUT_MSG);

0 commit comments

Comments
 (0)