Skip to content

Commit

Permalink
Cherry pick PR #2598: Make loader app withstand failed Crashpad db in…
Browse files Browse the repository at this point in the history
…it (#2626)

Refer to the original PR: #2598

Because of a missed nullptr check, the loader app currently crashes if
initialization of the Crashpad database fails during installation of the
Crashpad handler. There will be further investigation and improvements
here but for now, the loader app will continue to load Cobalt - just
without crash reporting for the current session.

We shoud add unit tests for this module soon. It would probably be best
to stub out the Starboard calls, which will require a little
refactoring.

b/329458881
b/326436503

Change-Id: Ibb9e9abe5e0295ddbc6d139f11d4ab6b3a1fbb4c

Co-authored-by: Holden Warriner <hwarriner@google.com>
  • Loading branch information
cobalt-github-releaser-bot and hlwarriner committed Mar 19, 2024
1 parent 148d5d1 commit f582ccf
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions third_party/crashpad/wrapper/wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,16 @@ base::FilePath GetDatabasePath() {
return base::FilePath(crashpad_directory_path.c_str());
}

void InitializeCrashpadDatabase(const base::FilePath database_directory_path) {
bool InitializeCrashpadDatabase(const base::FilePath database_directory_path) {
std::unique_ptr<::crashpad::CrashReportDatabase> database =
::crashpad::CrashReportDatabase::Initialize(database_directory_path);
if (!database) {
return false;
}

::crashpad::Settings* settings = database->GetSettings();
settings->SetUploadsEnabled(true);
return true;
}

std::string GetProductName() {
Expand Down Expand Up @@ -190,8 +195,8 @@ void InstallCrashpadHandler(bool start_at_crash,

const base::FilePath handler_path = GetPathToCrashpadHandlerBinary();
if (!SbFileExists(handler_path.value().c_str())) {
LOG(WARNING) << "crashpad_handler not at expected location of "
<< handler_path.value();
LOG(ERROR) << "crashpad_handler not at expected location of "
<< handler_path.value();
return;
}

Expand All @@ -207,7 +212,17 @@ void InstallCrashpadHandler(bool start_at_crash,
const std::map<std::string, std::string> platform_info = GetPlatformInfo();
default_annotations.insert(platform_info.begin(), platform_info.end());

InitializeCrashpadDatabase(database_directory_path);
if (!InitializeCrashpadDatabase(database_directory_path)) {
LOG(ERROR) << "Failed to initialize Crashpad database";

// As we investigate b/329458881 we may find that it's safe to continue with
// installation of the Crashpad handler here with the hope that the handler,
// when it runs, doesn't experience the same failure when initializing the
// Crashpad database. For now it seems safer to just give up on crash
// reporting for this particular Cobalt session.
return;
}

client->SetUnhandledSignals({});

if (start_at_crash)
Expand Down

0 comments on commit f582ccf

Please sign in to comment.