Skip to content

Commit

Permalink
[code cache] Add more checks to investigate a crash
Browse files Browse the repository at this point in the history
Bug: chromium:1221042
Change-Id: I142446fd0171db2737d6e4653adf260edb3b26de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2970066
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#894236}
  • Loading branch information
mythrialle authored and Chromium LUCI CQ committed Jun 21, 2021
1 parent ff3f913 commit d5c12fc
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion content/browser/service_worker/service_worker_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,34 @@ const base::UnguessableToken& ServiceWorkerHost::GetReportingSource() const {

void ServiceWorkerHost::CreateCodeCacheHost(
mojo::PendingReceiver<blink::mojom::CodeCacheHost> receiver) {
auto embedded_worker_status = version_->embedded_worker()->status();
// Due to IPC races it is possible that we receive code cache host requests
// when the worker is stopping. For ex:
// 1) Browser starts trying to stop, sends the Stop() IPC.
// 2) Renderer sends a CreateCodeCacheHost() IPC.
// 3) Renderer gets the Stop() IPC and realize it should try to stop the
// worker.
// Given the worker is stopping it is safe to ignore these messages.
if (embedded_worker_status == EmbeddedWorkerStatus::STOPPING)
return;

// Create a new CodeCacheHostImpl and bind it to the given receiver.
auto* process =
RenderProcessHost::FromID(version_->embedded_worker()->process_id());
// TODO(crbug:1221042): Remove the following checks once the investigation of
// the crashes is done.
if (process == nullptr) {
SCOPED_CRASH_KEY_STRING32(
"SWHost::CreateCodeCacheHost", "info",
base::StringPrintf("status:%d,pid:%d", embedded_worker_status,
version_->embedded_worker()->process_id()));
CHECK(false);
}
StoragePartition* storage_partition = process->GetStoragePartition();
code_cache_host_receivers_.Add(
std::make_unique<CodeCacheHostImpl>(
version_->embedded_worker()->process_id(), process,
process->GetStoragePartition()->GetGeneratedCodeCacheContext()),
storage_partition->GetGeneratedCodeCacheContext()),
std::move(receiver));
}

Expand Down

0 comments on commit d5c12fc

Please sign in to comment.