Restrict new crash_reporter flag to valid versions

Lacros can be up to 2 milestones ahead of ash (and consequently the
platform code), so until the crash_reporter change has been in for 2
milestones, we need to manually check version compatibility.

BUG=chromium:1420445
TEST=Build, deploy, check that flag is set only on right version

Change-Id: Ic99d5ac58840814f7eeecd47c628ea0e8107f675
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4308129
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Miriam Zimmerman 2023-03-03 13:34:02 -05:00 committed by Crashpad LUCI CQ
parent 90bba04e22
commit 707d0d4dac
2 changed files with 28 additions and 8 deletions

View File

@ -49,6 +49,10 @@ static_library("handler") {
"linux/cros_crash_report_exception_handler.cc",
"linux/cros_crash_report_exception_handler.h",
]
# TODO(https://crbug.com/1420445): Remove this config when M115 branches.
configs += [
"../build:crashpad_is_in_chromium",
]
}
if (crashpad_is_win) {

View File

@ -18,6 +18,9 @@
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#if defined(CRASHPAD_IS_IN_CHROMIUM)
#include "base/system/sys_info.h"
#endif // CRASHPAD_IS_IN_CHROMIUM
#include "client/settings.h"
#include "handler/linux/capture_snapshot.h"
#include "handler/minidump_to_upload_parameters.h"
@ -247,15 +250,28 @@ bool CrosCrashReportExceptionHandler::HandleExceptionWithConnection(
// crash_reporter needs to know the pid and uid of the crashing process.
std::vector<std::string> argv({"/sbin/crash_reporter"});
// Used to distinguish between non-fatal and fatal crashes.
const ExceptionSnapshot* const exception_snapshot = snapshot->Exception();
if (exception_snapshot) {
// convert to int32, since crashpad uses -1 as a signal for non-fatal
// crashes.
argv.push_back(base::StringPrintf(
"--chrome_signal=%d",
static_cast<int32_t>(exception_snapshot->Exception())));
#if defined(CRASHPAD_IS_IN_CHROMIUM)
int32_t major_version = 0, minor_version = 0, bugfix_version = 0;
base::SysInfo::OperatingSystemVersionNumbers(
&major_version, &minor_version, &bugfix_version);
// The version on which https://crrev.com/c/4265753 landed.
constexpr int32_t kFixedVersion = 15363;
// TODO(https://crbug.com/1420445): Remove this check (and the
// CRASHPAD_IS_IN_CHROMIUM defines) when M115 branches.
// (Lacros is guaranteed not to be more than 2 milestones ahead of ash, and
// M113 on ash has the relevant crash_reporter change.)
if (major_version >= kFixedVersion) {
// Used to distinguish between non-fatal and fatal crashes.
const ExceptionSnapshot* const exception_snapshot = snapshot->Exception();
if (exception_snapshot) {
// convert to int32, since crashpad uses -1 as a signal for non-fatal
// crashes.
argv.push_back(base::StringPrintf(
"--chrome_signal=%d",
static_cast<int32_t>(exception_snapshot->Exception())));
}
}
#endif // CRASHPAD_IS_IN_CHROMIUM
argv.push_back("--chrome_memfd=" + std::to_string(file_writer.fd()));