Merge "Fix the race condition between creating and killing process group" into udc-dev am: c601737f60
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22970327 Change-Id: Ic6263f1a6362009e254b6734d0b08481748c5f04 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -2300,6 +2300,8 @@ public final class ProcessList {
|
|||||||
|
|
||||||
final Process.ProcessStartResult startResult;
|
final Process.ProcessStartResult startResult;
|
||||||
boolean regularZygote = false;
|
boolean regularZygote = false;
|
||||||
|
app.mProcessGroupCreated = false;
|
||||||
|
app.mSkipProcessGroupCreation = false;
|
||||||
if (hostingRecord.usesWebviewZygote()) {
|
if (hostingRecord.usesWebviewZygote()) {
|
||||||
startResult = startWebView(entryPoint,
|
startResult = startWebView(entryPoint,
|
||||||
app.processName, uid, uid, gids, runtimeFlags, mountExternal,
|
app.processName, uid, uid, gids, runtimeFlags, mountExternal,
|
||||||
@@ -2328,19 +2330,29 @@ public final class ProcessList {
|
|||||||
isTopApp, app.getDisabledCompatChanges(), pkgDataInfoMap,
|
isTopApp, app.getDisabledCompatChanges(), pkgDataInfoMap,
|
||||||
allowlistedAppDataInfoMap, bindMountAppsData, bindMountAppStorageDirs,
|
allowlistedAppDataInfoMap, bindMountAppsData, bindMountAppStorageDirs,
|
||||||
new String[]{PROC_START_SEQ_IDENT + app.getStartSeq()});
|
new String[]{PROC_START_SEQ_IDENT + app.getStartSeq()});
|
||||||
|
// By now the process group should have been created by zygote.
|
||||||
|
app.mProcessGroupCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!regularZygote) {
|
if (!regularZygote) {
|
||||||
// webview and app zygote don't have the permission to create the nodes
|
// webview and app zygote don't have the permission to create the nodes
|
||||||
|
synchronized (app) {
|
||||||
|
if (!app.mSkipProcessGroupCreation) {
|
||||||
|
// If we're not told to skip the process group creation, go create it.
|
||||||
final int res = Process.createProcessGroup(uid, startResult.pid);
|
final int res = Process.createProcessGroup(uid, startResult.pid);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
if (res == -OsConstants.ESRCH) {
|
if (res == -OsConstants.ESRCH) {
|
||||||
Slog.e(ActivityManagerService.TAG, "Unable to create process group for "
|
Slog.e(ActivityManagerService.TAG,
|
||||||
|
"Unable to create process group for "
|
||||||
+ app.processName + " (" + startResult.pid + ")");
|
+ app.processName + " (" + startResult.pid + ")");
|
||||||
} else {
|
} else {
|
||||||
throw new AssertionError("Unable to create process group for "
|
throw new AssertionError("Unable to create process group for "
|
||||||
+ app.processName + " (" + startResult.pid + ")");
|
+ app.processName + " (" + startResult.pid + ")");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
app.mProcessGroupCreated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -424,6 +424,16 @@ class ProcessRecord implements WindowProcessListener {
|
|||||||
*/
|
*/
|
||||||
Runnable mSuccessorStartRunnable;
|
Runnable mSuccessorStartRunnable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the process group of this process has been created.
|
||||||
|
*/
|
||||||
|
volatile boolean mProcessGroupCreated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not we should skip the process group creation.
|
||||||
|
*/
|
||||||
|
volatile boolean mSkipProcessGroupCreation;
|
||||||
|
|
||||||
void setStartParams(int startUid, HostingRecord hostingRecord, String seInfo,
|
void setStartParams(int startUid, HostingRecord hostingRecord, String seInfo,
|
||||||
long startUptime, long startElapsedTime) {
|
long startUptime, long startElapsedTime) {
|
||||||
this.mStartUid = startUid;
|
this.mStartUid = startUid;
|
||||||
@@ -1192,8 +1202,26 @@ class ProcessRecord implements WindowProcessListener {
|
|||||||
EventLog.writeEvent(EventLogTags.AM_KILL,
|
EventLog.writeEvent(EventLogTags.AM_KILL,
|
||||||
userId, mPid, processName, mState.getSetAdj(), reason);
|
userId, mPid, processName, mState.getSetAdj(), reason);
|
||||||
Process.killProcessQuiet(mPid);
|
Process.killProcessQuiet(mPid);
|
||||||
if (!asyncKPG) Process.sendSignalToProcessGroup(uid, mPid, OsConstants.SIGKILL);
|
final boolean killProcessGroup;
|
||||||
|
if (mHostingRecord != null
|
||||||
|
&& (mHostingRecord.usesWebviewZygote() || mHostingRecord.usesAppZygote())) {
|
||||||
|
synchronized (ProcessRecord.this) {
|
||||||
|
killProcessGroup = mProcessGroupCreated;
|
||||||
|
if (!killProcessGroup) {
|
||||||
|
// The process group hasn't been created, request to skip it.
|
||||||
|
mSkipProcessGroupCreation = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
killProcessGroup = true;
|
||||||
|
}
|
||||||
|
if (killProcessGroup) {
|
||||||
|
if (asyncKPG) {
|
||||||
ProcessList.killProcessGroup(uid, mPid);
|
ProcessList.killProcessGroup(uid, mPid);
|
||||||
|
} else {
|
||||||
|
Process.sendSignalToProcessGroup(uid, mPid, OsConstants.SIGKILL);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mPendingStart = false;
|
mPendingStart = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user