Commit 0b4a587f authored by Joshua Peraza's avatar Joshua Peraza Committed by Commit Bot

Update Crashpad to 676a190308b1492bdb6c1f8889247d4dfedefaf1

c405d0ea2cbd make PruneCrashReportDatabase return the number of pruned
             crash reports
eff0680c1393 linux: silence logs on client disconnect
676a190308b1 linux: fix --monitor-self

Change-Id: I951396961c62eec998375307e9820e2fa68ed235
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1830289Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701364}
parent 6d4c95c1
...@@ -2,7 +2,7 @@ Name: Crashpad ...@@ -2,7 +2,7 @@ Name: Crashpad
Short Name: crashpad Short Name: crashpad
URL: https://crashpad.chromium.org/ URL: https://crashpad.chromium.org/
Version: unknown Version: unknown
Revision: edbbc4609d2d0703ed73ba9293971f1346234313 Revision: 676a190308b1492bdb6c1f8889247d4dfedefaf1
License: Apache 2.0 License: Apache 2.0
License File: crashpad/LICENSE License File: crashpad/LICENSE
Security Critical: yes Security Critical: yes
......
...@@ -352,7 +352,6 @@ bool CrashpadClient::StartHandler( ...@@ -352,7 +352,6 @@ bool CrashpadClient::StartHandler(
const std::vector<std::string>& arguments, const std::vector<std::string>& arguments,
bool restartable, bool restartable,
bool asynchronous_start) { bool asynchronous_start) {
DCHECK(!restartable);
DCHECK(!asynchronous_start); DCHECK(!asynchronous_start);
ScopedFileHandle client_sock, handler_sock; ScopedFileHandle client_sock, handler_sock;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "client/prune_crash_reports.h" #include "client/prune_crash_reports.h"
#include <sys/stat.h> #include <sys/stat.h>
#include <stdint.h>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
...@@ -24,7 +25,7 @@ ...@@ -24,7 +25,7 @@
namespace crashpad { namespace crashpad {
void PruneCrashReportDatabase(CrashReportDatabase* database, size_t PruneCrashReportDatabase(CrashReportDatabase* database,
PruneCondition* condition) { PruneCondition* condition) {
std::vector<CrashReportDatabase::Report> all_reports; std::vector<CrashReportDatabase::Report> all_reports;
CrashReportDatabase::OperationStatus status; CrashReportDatabase::OperationStatus status;
...@@ -32,14 +33,14 @@ void PruneCrashReportDatabase(CrashReportDatabase* database, ...@@ -32,14 +33,14 @@ void PruneCrashReportDatabase(CrashReportDatabase* database,
status = database->GetPendingReports(&all_reports); status = database->GetPendingReports(&all_reports);
if (status != CrashReportDatabase::kNoError) { if (status != CrashReportDatabase::kNoError) {
LOG(ERROR) << "PruneCrashReportDatabase: Failed to get pending reports"; LOG(ERROR) << "PruneCrashReportDatabase: Failed to get pending reports";
return; return 0;
} }
std::vector<CrashReportDatabase::Report> completed_reports; std::vector<CrashReportDatabase::Report> completed_reports;
status = database->GetCompletedReports(&completed_reports); status = database->GetCompletedReports(&completed_reports);
if (status != CrashReportDatabase::kNoError) { if (status != CrashReportDatabase::kNoError) {
LOG(ERROR) << "PruneCrashReportDatabase: Failed to get completed reports"; LOG(ERROR) << "PruneCrashReportDatabase: Failed to get completed reports";
return; return 0;
} }
all_reports.insert(all_reports.end(), completed_reports.begin(), all_reports.insert(all_reports.end(), completed_reports.begin(),
completed_reports.end()); completed_reports.end());
...@@ -50,16 +51,21 @@ void PruneCrashReportDatabase(CrashReportDatabase* database, ...@@ -50,16 +51,21 @@ void PruneCrashReportDatabase(CrashReportDatabase* database,
return lhs.creation_time > rhs.creation_time; return lhs.creation_time > rhs.creation_time;
}); });
size_t num_pruned = 0;
for (const auto& report : all_reports) { for (const auto& report : all_reports) {
if (condition->ShouldPruneReport(report)) { if (condition->ShouldPruneReport(report)) {
status = database->DeleteReport(report.uuid); status = database->DeleteReport(report.uuid);
if (status != CrashReportDatabase::kNoError) { if (status != CrashReportDatabase::kNoError) {
LOG(ERROR) << "Database Pruning: Failed to remove report " LOG(ERROR) << "Database Pruning: Failed to remove report "
<< report.uuid.ToString(); << report.uuid.ToString();
} else {
num_pruned++;
} }
} }
} }
return num_pruned;
// TODO(rsesek): For databases that do not use a directory structure, it is // TODO(rsesek): For databases that do not use a directory structure, it is
// possible for the metadata sidecar to become corrupted and thus leave // possible for the metadata sidecar to become corrupted and thus leave
// orphaned crash report files on-disk. https://crashpad.chromium.org/bug/66 // orphaned crash report files on-disk. https://crashpad.chromium.org/bug/66
......
...@@ -37,8 +37,10 @@ class PruneCondition; ...@@ -37,8 +37,10 @@ class PruneCondition;
//! \param[in] database The database from which crash reports will be deleted. //! \param[in] database The database from which crash reports will be deleted.
//! \param[in] condition The condition against which all reports in the database //! \param[in] condition The condition against which all reports in the database
//! will be evaluated. //! will be evaluated.
void PruneCrashReportDatabase(CrashReportDatabase* database, //!
PruneCondition* condition); //! \return The number of deleted crash reports.
size_t PruneCrashReportDatabase(CrashReportDatabase* database,
PruneCondition* condition);
std::unique_ptr<PruneCondition> GetDefaultDatabasePruneCondition(); std::unique_ptr<PruneCondition> GetDefaultDatabasePruneCondition();
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "client/prune_crash_reports.h" #include "client/prune_crash_reports.h"
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <algorithm> #include <algorithm>
...@@ -204,11 +205,12 @@ TEST(PruneCrashReports, PruneOrder) { ...@@ -204,11 +205,12 @@ TEST(PruneCrashReports, PruneOrder) {
using ::testing::Return; using ::testing::Return;
using ::testing::SetArgPointee; using ::testing::SetArgPointee;
const size_t kNumReports = 10;
std::vector<CrashReportDatabase::Report> reports; std::vector<CrashReportDatabase::Report> reports;
for (int i = 0; i < 10; ++i) { for (size_t i = 0; i < kNumReports; ++i) {
CrashReportDatabase::Report temp; CrashReportDatabase::Report temp;
temp.uuid.data_1 = i; temp.uuid.data_1 = static_cast<uint32_t>(i);
temp.creation_time = NDaysAgo(i * 10); temp.creation_time = NDaysAgo(static_cast<int>(i) * 10);
reports.push_back(temp); reports.push_back(temp);
} }
std::mt19937 urng(std::random_device{}()); std::mt19937 urng(std::random_device{}());
...@@ -231,7 +233,7 @@ TEST(PruneCrashReports, PruneOrder) { ...@@ -231,7 +233,7 @@ TEST(PruneCrashReports, PruneOrder) {
} }
StaticCondition delete_all(true); StaticCondition delete_all(true);
PruneCrashReportDatabase(&db, &delete_all); EXPECT_EQ(PruneCrashReportDatabase(&db, &delete_all), kNumReports);
} }
} // namespace } // namespace
......
...@@ -263,8 +263,6 @@ class CallMetricsRecordNormalExit { ...@@ -263,8 +263,6 @@ class CallMetricsRecordNormalExit {
#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_ANDROID) #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_ANDROID)
Signals::OldActions g_old_crash_signal_handlers;
void HandleCrashSignal(int sig, siginfo_t* siginfo, void* context) { void HandleCrashSignal(int sig, siginfo_t* siginfo, void* context) {
MetricsRecordExit(Metrics::LifetimeMilestone::kCrashed); MetricsRecordExit(Metrics::LifetimeMilestone::kCrashed);
...@@ -299,9 +297,7 @@ void HandleCrashSignal(int sig, siginfo_t* siginfo, void* context) { ...@@ -299,9 +297,7 @@ void HandleCrashSignal(int sig, siginfo_t* siginfo, void* context) {
} }
Metrics::HandlerCrashed(metrics_code); Metrics::HandlerCrashed(metrics_code);
struct sigaction* old_action = Signals::RestoreHandlerAndReraiseSignalOnReturn(siginfo, nullptr);
g_old_crash_signal_handlers.ActionForSignal(sig);
Signals::RestoreHandlerAndReraiseSignalOnReturn(siginfo, old_action);
} }
void HandleTerminateSignal(int sig, siginfo_t* siginfo, void* context) { void HandleTerminateSignal(int sig, siginfo_t* siginfo, void* context) {
...@@ -309,13 +305,13 @@ void HandleTerminateSignal(int sig, siginfo_t* siginfo, void* context) { ...@@ -309,13 +305,13 @@ void HandleTerminateSignal(int sig, siginfo_t* siginfo, void* context) {
Signals::RestoreHandlerAndReraiseSignalOnReturn(siginfo, nullptr); Signals::RestoreHandlerAndReraiseSignalOnReturn(siginfo, nullptr);
} }
#if defined(OS_MACOSX)
void ReinstallCrashHandler() { void ReinstallCrashHandler() {
// This is used to re-enable the metrics-recording crash handler after // This is used to re-enable the metrics-recording crash handler after
// MonitorSelf() sets up a Crashpad exception handler. On macOS, the // MonitorSelf() sets up a Crashpad exception handler. On macOS, the
// metrics-recording handler uses signals and the Crashpad handler uses Mach // metrics-recording handler uses signals and the Crashpad handler uses Mach
// exceptions, so there’s nothing to re-enable. // exceptions, so there’s nothing to re-enable.
// On Linux, the signal handler installed by StartHandler() restores the
// previously installed signal handler by default.
} }
void InstallCrashHandler() { void InstallCrashHandler() {
...@@ -325,6 +321,8 @@ void InstallCrashHandler() { ...@@ -325,6 +321,8 @@ void InstallCrashHandler() {
Signals::InstallTerminateHandlers(HandleTerminateSignal, 0, nullptr); Signals::InstallTerminateHandlers(HandleTerminateSignal, 0, nullptr);
} }
#if defined(OS_MACOSX)
struct ResetSIGTERMTraits { struct ResetSIGTERMTraits {
static struct sigaction* InvalidValue() { static struct sigaction* InvalidValue() {
return nullptr; return nullptr;
...@@ -349,21 +347,6 @@ void HandleSIGTERM(int sig, siginfo_t* siginfo, void* context) { ...@@ -349,21 +347,6 @@ void HandleSIGTERM(int sig, siginfo_t* siginfo, void* context) {
g_exception_handler_server->Stop(); g_exception_handler_server->Stop();
} }
#else
void ReinstallCrashHandler() {
// This is used to re-enable the metrics-recording crash handler after
// MonitorSelf() sets up a Crashpad signal handler.
Signals::InstallCrashHandlers(
HandleCrashSignal, 0, &g_old_crash_signal_handlers);
}
void InstallCrashHandler() {
ReinstallCrashHandler();
Signals::InstallTerminateHandlers(HandleTerminateSignal, 0, nullptr);
}
#endif // OS_MACOSX #endif // OS_MACOSX
#elif defined(OS_WIN) #elif defined(OS_WIN)
...@@ -473,7 +456,7 @@ void MonitorSelf(const Options& options) { ...@@ -473,7 +456,7 @@ void MonitorSelf(const Options& options) {
// instance of crashpad_handler to be writing metrics at a time, and it should // instance of crashpad_handler to be writing metrics at a time, and it should
// be the primary instance. // be the primary instance.
CrashpadClient crashpad_client; CrashpadClient crashpad_client;
#if defined(OS_LINUX) || defined(OS_ANDROID) #if defined(OS_ANDROID)
if (!crashpad_client.StartHandlerAtCrash(executable_path, if (!crashpad_client.StartHandlerAtCrash(executable_path,
options.database, options.database,
base::FilePath(), base::FilePath(),
......
...@@ -168,17 +168,17 @@ bool UnixCredentialSocket::RecvMsg(int fd, ...@@ -168,17 +168,17 @@ bool UnixCredentialSocket::RecvMsg(int fd,
return false; return false;
} }
// Credentials are missing from the message either when the recv socket wasn't
// configured with SO_PASSCRED or when all sending sockets have been closed.
// In the latter case, res == 0. This case is also indistinguishable from an
// empty message sent to a recv socket which hasn't set SO_PASSCRED.
if (!local_creds) { if (!local_creds) {
LOG(ERROR) << "missing credentials"; LOG_IF(ERROR, res != 0) << "missing credentials";
return false; return false;
} }
// res == 0 may also indicate that the sending socket disconnected, but in
// that case, the message will also have missing or invalid credentials.
if (static_cast<size_t>(res) != buf_size) { if (static_cast<size_t>(res) != buf_size) {
if (res != 0 || (local_creds && local_creds->pid != 0)) { LOG(ERROR) << "incorrect payload size " << res;
LOG(ERROR) << "incorrect payload size " << res;
}
return false; return false;
} }
......
...@@ -76,7 +76,11 @@ class UnixCredentialSocket { ...@@ -76,7 +76,11 @@ class UnixCredentialSocket {
//! \param[out] creds The credentials of the sender. //! \param[out] creds The credentials of the sender.
//! \param[out] fds The recieved file descriptors. Optional. If `nullptr`, all //! \param[out] fds The recieved file descriptors. Optional. If `nullptr`, all
//! received file descriptors will be closed. //! received file descriptors will be closed.
//! \return `true` on success. Otherwise, `false`, with a message logged. //! \return `true` on success. Otherwise, `false`, with a message logged. No
//! message will be logged if the message was detected to be an EOF
//! condition triggered by all clients disconnecting. This case is
//! indistinguishable from misuses of this interface that haven't set
//! `SO_PASSCRED` on \a fd.
static bool RecvMsg(int fd, static bool RecvMsg(int fd,
void* buf, void* buf,
size_t buf_size, size_t buf_size,
......
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