Skip to content

Commit

Permalink
Introduce --sandbox2_log_unobtainable_stack_traces_errors.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
apbianco authored and copybara-github committed Jun 5, 2024
1 parent 78ffdb1 commit 4674377
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sandboxed_api/sandbox2/monitor_ptrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -232,7 +235,9 @@ void PtraceMonitor::SetAdditionalResultInfo(std::unique_ptr<Regs> regs) {
absl::StatusOr<std::vector<std::string>> 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);
Expand Down

0 comments on commit 4674377

Please sign in to comment.