Commit 73adbb95 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

android: Fix OOB crash in ChildProcessRanking

ChildProcessLauncherHelperImpl assumes onConnectionEstablished and
onConnectionLost are paired when in reality they might not be. Former is
called after setupConnection is completed (when child sends its pid),
and the latter is called from onServiceDisconnected (and posted once).
It is possible that the child dies after onServiceConnected, but before
setupConnection is complete.

It should not be possible for onConnectionEstablished to come after
onServiceDisconnected however.

Add a check in onConnectionLost for this case and skip the rest of clean
up if needed.

Bug: 1013667
Change-Id: I56d83863be440810238d743083250c72c48160c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1860036Reviewed-by: default avatarssid <ssid@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705881}
parent e9730006
......@@ -162,7 +162,12 @@ public final class ChildProcessLauncherHelperImpl {
public void onConnectionLost(ChildProcessConnection connection) {
assert LauncherThread.runningOnLauncherThread();
if (connection.getPid() == 0) return;
sLauncherByPid.remove(connection.getPid());
ChildProcessLauncherHelperImpl result =
sLauncherByPid.remove(connection.getPid());
// Child process might die before onConnectionEstablished.
if (result == null) return;
if (mBindingManager != null) mBindingManager.removeConnection(connection);
if (mRanking != null) {
setReverseRankWhenConnectionLost(mRanking.getReverseRank(connection));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment