From 467437729a6292ed1dbc9de11fafbdd35614b346 Mon Sep 17 00:00:00 2001 From: Alex Petit-Bianco Date: Wed, 5 Jun 2024 06:30:27 -0700 Subject: [PATCH] Introduce --sandbox2_log_unobtainable_stack_traces_errors. This allows to disable logging errors encountered while trying to obtain stack traces. The default flag value doesn't change the existing behavior. PiperOrigin-RevId: 640505520 Change-Id: Ib24e688f38906cd2a582d0d3253a17d6ee393249 --- sandboxed_api/sandbox2/monitor_ptrace.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sandboxed_api/sandbox2/monitor_ptrace.cc b/sandboxed_api/sandbox2/monitor_ptrace.cc index fed64190..f6d95f7e 100644 --- a/sandboxed_api/sandbox2/monitor_ptrace.cc +++ b/sandboxed_api/sandbox2/monitor_ptrace.cc @@ -71,6 +71,9 @@ ABSL_FLAG(bool, sandbox2_log_all_stack_traces, false, "If set, sandbox2 monitor will log stack traces of all monitored " "threads/processes that are reported to terminate with a signal."); +ABSL_FLAG(bool, sandbox2_log_unobtainable_stack_traces_errors, true, + "If set, unobtainable stack trace will be logged as errors."); + ABSL_FLAG(absl::Duration, sandbox2_stack_traces_collection_timeout, absl::Seconds(1), "How much time should be spent on logging threads' stack traces on " @@ -232,7 +235,9 @@ void PtraceMonitor::SetAdditionalResultInfo(std::unique_ptr regs) { absl::StatusOr> stack_trace = GetAndLogStackTrace(result_.GetRegs()); if (!stack_trace.ok()) { - LOG(ERROR) << "Could not obtain stack trace: " << stack_trace.status(); + LOG_IF(ERROR, + absl::GetFlag(FLAGS_sandbox2_log_unobtainable_stack_traces_errors)) + << "Could not obtain stack trace: " << stack_trace.status(); return; } result_.set_stack_trace(*stack_trace);