Skip to content

Commit

Permalink
debug: improving symbolization further (#3728)
Browse files Browse the repository at this point in the history
Initializing absl::Symbolize for improved symbolization in a few corner cases.

Risk Level: Low
Testing: //test/server:backtrace_test looks good
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
  • Loading branch information
alyssawilk authored and htuch committed Jun 26, 2018
1 parent 1413d56 commit 6521aa0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/exe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ envoy_cc_library(
envoy_cc_library(
name = "envoy_main_entry_lib",
srcs = ["main.cc"],
external_deps = [
"abseil_symbolize",
],
deps = [
":envoy_main_common_lib",
],
Expand Down
7 changes: 7 additions & 0 deletions source/exe/main.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "exe/main_common.h"

#include "absl/debugging/symbolize.h"

// NOLINT(namespace-envoy)

/**
Expand All @@ -10,6 +12,11 @@
* after setting up command line options.
*/
int main(int argc, char** argv) {
#ifndef __APPLE__
// absl::Symbolize mostly works without this, but this improves corner case
// handling, such as running in a chroot jail.
absl::InitializeSymbolizer(argv[0]);
#endif
std::unique_ptr<Envoy::MainCommon> main_common;

// Initialize the server's main context under a try/catch loop and simply return EXIT_FAILURE
Expand Down
3 changes: 3 additions & 0 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ envoy_cc_test_library(
"main.cc",
"test_runner.h",
],
external_deps = [
"abseil_symbolize",
],
deps = [
"//source/common/common:logger_lib",
"//source/common/common:thread_lib",
Expand Down
5 changes: 5 additions & 0 deletions test/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "test/test_common/environment.h"
#include "test/test_runner.h"

#include "absl/debugging/symbolize.h"

#ifdef ENVOY_HANDLE_SIGNALS
#include "exe/signal_action.h"
#endif
Expand All @@ -14,6 +16,9 @@ const char* __asan_default_options() {
// The main entry point (and the rest of this file) should have no logic in it,
// this allows overriding by site specific versions of main.cc.
int main(int argc, char** argv) {
#ifndef __APPLE__
absl::InitializeSymbolizer(argv[0]);
#endif
#ifdef ENVOY_HANDLE_SIGNALS
// Enabled by default. Control with "bazel --define=signal_trace=disabled"
Envoy::SignalAction handle_sigs;
Expand Down

0 comments on commit 6521aa0

Please sign in to comment.