Skip to content

Commit

Permalink
Add DumpWithoutCrashing() for the HashMap insersion in SWGlobalScope
Browse files Browse the repository at this point in the history
The CL to investigate crbug.com/1492640, and is splitted from
crrev.com/c/4942552.

We assume that null tokens are inserted as a key of
|race_network_request_loader_factories_| in ServiceWorkerGlobalScope.
DumpWithoutCrashing() added by this CL gives us more clarity why this
happens.

Bug: 1492640
Change-Id: I825fe83525bee8d597ff02449e14a5ca4fd3cbbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4957503
Reviewed-by: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
Commit-Queue: Shunya Shishido <sisidovski@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1213213}
  • Loading branch information
sisidovski authored and Chromium LUCI CQ committed Oct 22, 2023
1 parent 2190050 commit dee6a36
Showing 1 changed file with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <memory>
#include <utility>

#include "base/debug/dump_without_crashing.h"
#include "base/feature_list.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
Expand Down Expand Up @@ -1550,10 +1551,52 @@ void ServiceWorkerGlobalScope::StartFetchEvent(

if (params->race_network_request_loader_factory &&
params->request->service_worker_race_network_request_token) {
race_network_request_loader_factories_.insert(
auto insert_result = race_network_request_loader_factories_.insert(
String(params->request->service_worker_race_network_request_token
->ToString()),
std::move(params->race_network_request_loader_factory));

// DumpWithoutCrashing if the token is empty, or not inserted as a new entry
// to |race_network_request_loader_factories_|.
// TODO(crbug.com/1492640) Remove DumpWithoutCrashing once we collect data
// and identify the cause.
static bool has_dumped_without_crashing_for_empty_token = false;
static bool has_dumped_without_crashing_for_not_new_entry = false;
if (!has_dumped_without_crashing_for_empty_token &&
params->request->service_worker_race_network_request_token
->is_empty()) {
has_dumped_without_crashing_for_empty_token = true;
SCOPED_CRASH_KEY_BOOL(
"SWGlobalScope", "empty_race_token",
params->request->service_worker_race_network_request_token
->is_empty());
SCOPED_CRASH_KEY_STRING64(
"SWGlobalScope", "race_token_string",
params->request->service_worker_race_network_request_token
->ToString());
SCOPED_CRASH_KEY_BOOL("SWGlobalScope", "race_insert_new_entry",
insert_result.is_new_entry);
SCOPED_CRASH_KEY_STRING256("SWGlobalScope", "race_request_url",
params->request->url.GetString().Utf8());
base::debug::DumpWithoutCrashing();
}
if (!has_dumped_without_crashing_for_not_new_entry &&
!insert_result.is_new_entry) {
has_dumped_without_crashing_for_not_new_entry = true;
SCOPED_CRASH_KEY_BOOL(
"SWGlobalScope", "empty_race_token",
params->request->service_worker_race_network_request_token
->is_empty());
SCOPED_CRASH_KEY_STRING64(
"SWGlobalScope", "race_token_string",
params->request->service_worker_race_network_request_token
->ToString());
SCOPED_CRASH_KEY_BOOL("SWGlobalScope", "race_insert_new_entry",
insert_result.is_new_entry);
SCOPED_CRASH_KEY_STRING256("SWGlobalScope", "race_request_url",
params->request->url.GetString().Utf8());
base::debug::DumpWithoutCrashing();
}
}

Request* request = Request::Create(
Expand Down

0 comments on commit dee6a36

Please sign in to comment.