You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2019/03/27 15:50:17 UTC

[impala] 02/04: IMPALA-7129: Fixing path to UBSAN suppressions.

This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/impala.git

commit c747c755033840fc4c35cc8109f1dc9956a779cb
Author: Philip Zeyliger <ph...@cloudera.com>
AuthorDate: Mon Jul 9 14:22:27 2018 -0700

    IMPALA-7129: Fixing path to UBSAN suppressions.
    
    This pins the suppression file path at build time.
    
    It turns out that calling getenv("IMPALA_HOME") was returning null at
    the time the undefined behavior was being initialized. I suspect this is
    an initialization ordering issue. To step around the issue, I'm simply
    using a preprocessor macro to get at the suppression file path.
    
    I was able to reproduce the error by running the catalogd binary
    outside of $IMPALA_HOME. Before this change, that would fail reliably.
    
    Change-Id: I5295c2d1bddbea585a761b85a51eadecf10d191d
    Reviewed-on: http://gerrit.cloudera.org:8080/10895
    Reviewed-by: Jim Apple <jb...@apache.org>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/CMakeLists.txt     | 8 +++++++-
 be/src/common/init.cc | 5 +----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 1bbcd24..d2757c1 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -112,7 +112,13 @@ SET(CXX_FLAGS_ADDRESS_SANITIZER
 
 # Set the flags to the undefined behavior sanitizer, also known as "ubsan"
 # Turn on sanitizer and debug symbols to get stack traces:
-SET(CXX_FLAGS_UBSAN "${CXX_CLANG_FLAGS} -ggdb3 -fno-omit-frame-pointer -fsanitize=undefined -DUNDEFINED_SANITIZER")
+SET(CXX_FLAGS_UBSAN "${CXX_CLANG_FLAGS} -ggdb3 -fno-omit-frame-pointer -fsanitize=undefined")
+# Set preprocessor macros to facilitate initialization the relevant configuration.
+SET(CXX_FLAGS_UBSAN "${CXX_FLAGS_UBSAN} -DUNDEFINED_SANITIZER")
+# Calling getenv() in __ubsan_default_options doesn't work, likely because of
+# initialization ordering. We need to double-quote to create a macro that expands
+# to a string-literal.
+SET(CXX_FLAGS_UBSAN "${CXX_FLAGS_UBSAN} -DUNDEFINED_SANITIZER_SUPPRESSIONS=\\\"$ENV{IMPALA_HOME}/bin/ubsan-suppressions.txt\\\"")
 # Add flags to enable symbol resolution in the stack traces:
 SET(CXX_FLAGS_UBSAN "${CXX_FLAGS_UBSAN} -rtlib=compiler-rt -lgcc_s")
 # Ignore a number of noisy errors with too many false positives:
diff --git a/be/src/common/init.cc b/be/src/common/init.cc
index e9bdfdc..c763c91 100644
--- a/be/src/common/init.cc
+++ b/be/src/common/init.cc
@@ -296,9 +296,6 @@ extern "C" const char *__tsan_default_options() {
 // Default UBSAN_OPTIONS. Override by setting environment variable $UBSAN_OPTIONS.
 #if defined(UNDEFINED_SANITIZER)
 extern "C" const char *__ubsan_default_options() {
-  static const string default_options = Substitute(
-      "print_stacktrace=1 suppressions=$0/bin/ubsan-suppressions.txt",
-      getenv("IMPALA_HOME") == nullptr ? "." : getenv("IMPALA_HOME"));
-  return default_options.c_str();
+  return "print_stacktrace=1 suppressions=" UNDEFINED_SANITIZER_SUPPRESSIONS;
 }
 #endif