summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Egesdahl <ryan.egesdahl@mongodb.com>2020-07-30 11:03:02 -0700
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-13 06:06:23 +0000
commit20f26290c6e6d58a8ae40a1484f1eb9f2fa1dc83 (patch)
treea88f14b50ea380b064674ffb11c8455ad6c3f1e4
parent031ce11e88e9a98136eb99943162809554981dbb (diff)
downloadmongo-20f26290c6e6d58a8ae40a1484f1eb9f2fa1dc83.tar.gz
SERVER-49857 Explicit llvm-symbolizer path handling with {A,T,UB}SAN
The toolchain llvm-symbolizer was never actually in PATH despite the toolchain being appended to it in evergreen.yml, causing confusion while attempting to diagnose an apparent symbolization failure. This change explicitly sets the path to llvm-symbolizer for all sanitizer build variants and removes the last vestiges of the non-working discovery method. (cherry picked from commit 20ed5d51cb1c82597f65967be69b81e6e72c0413)
-rw-r--r--SConstruct75
-rw-r--r--etc/evergreen.yml31
-rw-r--r--etc/scons/mongodbtoolchain_v3_clang.vars1
3 files changed, 70 insertions, 37 deletions
diff --git a/SConstruct b/SConstruct
index 208ebad61d9..eb924a4c580 100644
--- a/SConstruct
+++ b/SConstruct
@@ -288,11 +288,6 @@ add_option('sanitize-coverage',
metavar='cov1,cov2,...covN',
)
-add_option('llvm-symbolizer',
- default='llvm-symbolizer',
- help='name of (or path to) the LLVM symbolizer',
-)
-
add_option('durableDefaultOn',
help='have durable default to on',
nargs=0,
@@ -826,6 +821,9 @@ env_vars.Add('LINKFLAGS',
help='Sets flags for the linker',
converter=variable_shlex_converter)
+env_vars.Add('LLVM_SYMBOLIZER',
+ help='Name of or path to the LLVM symbolizer')
+
env_vars.Add('MAXLINELENGTH',
help='Maximum line length before using temp files',
# This is very small, but appears to be the least upper bound
@@ -3001,21 +2999,20 @@ def doConfigure(myenv):
LINKFLAGS="${SANITIZER_BLACKLIST_GENERATOR}",
)
- llvm_symbolizer = get_option('llvm-symbolizer')
- if os.path.isabs(llvm_symbolizer):
+ symbolizer_option = ""
+ if env['LLVM_SYMBOLIZER']:
+ llvm_symbolizer = env['LLVM_SYMBOLIZER']
+
+ if not os.path.isabs(llvm_symbolizer):
+ llvm_symbolizer = myenv.WhereIs(llvm_symbolizer)
+
if not myenv.File(llvm_symbolizer).exists():
- print("WARNING: Specified symbolizer '%s' not found" % llvm_symbolizer)
- llvm_symbolizer = None
- else:
- llvm_symbolizer = myenv.WhereIs(llvm_symbolizer)
+ myenv.FatalError(f"Symbolizer binary at path {llvm_symbolizer} does not exist")
- tsan_options = ""
- if llvm_symbolizer:
- myenv['ENV']['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer
- myenv['ENV']['LSAN_SYMBOLIZER_PATH'] = llvm_symbolizer
- tsan_options = "external_symbolizer_path=\"%s\" " % llvm_symbolizer
- elif using_lsan:
- myenv.FatalError("Using the leak sanitizer requires a valid symbolizer")
+ symbolizer_option = f":external_symbolizer_path=\"{llvm_symbolizer}\""
+
+ elif using_asan or using_tsan or using_ubsan:
+ myenv.FatalError("The address, thread, and undefined behavior sanitizers require llvm-symbolizer for meaningful reports")
if using_asan:
# Unfortunately, abseil requires that we make these macros
@@ -3024,10 +3021,43 @@ def doConfigure(myenv):
# compiler. We do this unconditionally because abseil is
# basically pervasive via the 'base' library.
myenv.AppendUnique(CPPDEFINES=['ADDRESS_SANITIZER'])
+ # If anything is changed, added, or removed in either asan_options or
+ # lsan_options, be sure to make the corresponding changes to the
+ # appropriate build variants in etc/evergreen.yml
+ asan_options = "detect_leaks=1:check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1"
+ lsan_options = f"report_objects=1:suppressions={myenv.File('#etc/lsan.suppressions').abspath}"
+ env['ENV']['ASAN_OPTIONS'] = asan_options + symbolizer_option
+ env['ENV']['LSAN_OPTIONS'] = lsan_options + symbolizer_option
if using_tsan:
- tsan_options += "suppressions=\"%s\" " % myenv.File("#etc/tsan.suppressions").abspath
- myenv['ENV']['TSAN_OPTIONS'] = tsan_options
+
+ if use_libunwind:
+ # TODO: SERVER-48622
+ #
+ # See https://github.com/google/sanitizers/issues/943
+ # for why we disallow combining TSAN with
+ # libunwind. We could, atlernatively, have added logic
+ # to automate the decision about whether to enable
+ # libunwind based on whether TSAN is enabled, but that
+ # logic is already complex, and it feels better to
+ # make it explicit that using TSAN means you won't get
+ # the benefits of libunwind. Fixing this is:
+ env.FatalError("Cannot use libunwind with TSAN, please add --use-libunwind=off to your compile flags")
+
+ # If anything is changed, added, or removed in
+ # tsan_options, be sure to make the corresponding changes
+ # to the appropriate build variants in etc/evergreen.yml
+ #
+ # TODO SERVER-49121: die_after_fork=0 is a temporary
+ # setting to allow tests to continue while we figure out
+ # why we're running afoul of it.
+ #
+ # TODO SERVER-48490: report_thread_leaks=0 suppresses
+ # reporting thread leaks, which we have because we don't
+ # do a clean shutdown of the ServiceContext.
+ #
+ tsan_options = f"halt_on_error=1:report_thread_leaks=0:die_after_fork=0:suppressions={myenv.File('#etc/tsan.suppressions').abspath}"
+ myenv['ENV']['TSAN_OPTIONS'] = tsan_options + symbolizer_option
myenv.AppendUnique(CPPDEFINES=['THREAD_SANITIZER'])
if using_ubsan:
@@ -3039,6 +3069,11 @@ def doConfigure(myenv):
if not using_fsan and not AddToCCFLAGSIfSupported(myenv, "-fno-sanitize-recover"):
AddToCCFLAGSIfSupported(myenv, "-fno-sanitize-recover=undefined")
myenv.AppendUnique(CPPDEFINES=['UNDEFINED_BEHAVIOR_SANITIZER'])
+ # If anything is changed, added, or removed in ubsan_options, be
+ # sure to make the corresponding changes to the appropriate build
+ # variants in etc/evergreen.yml
+ ubsan_options = "print_stacktrace=1"
+ myenv['ENV']['UBSAN_OPTIONS'] = ubsan_options + symbolizer_option
if myenv.ToolchainIs('msvc') and optBuild:
# http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
diff --git a/etc/evergreen.yml b/etc/evergreen.yml
index 79c8bc819f7..5b431f99efb 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -1403,7 +1403,6 @@ functions:
${gcov_environment} \
${lang_environment} \
${san_options} \
- ${san_symbolizer} \
${snmp_config_path} \
${resmoke_wrapper} \
$python buildscripts/resmoke.py run \
@@ -12128,10 +12127,10 @@ buildvariants:
stepback: false
expansions:
additional_package_targets: archive-mongocryptd archive-mongocryptd-debug
- # We need llvm-symbolizer in the PATH for ASAN for clang-3.7 or later.
- variant_path_suffix: /opt/mongodbtoolchain/v3/bin
lang_environment: LANG=C
- san_options: LSAN_OPTIONS="suppressions=etc/lsan.suppressions:report_objects=1" ASAN_OPTIONS=detect_leaks=1:check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1
+ # If you add anything to san_options, make sure the appropriate changes are
+ # also made to SConstruct.
+ san_options: LSAN_OPTIONS="suppressions=etc/lsan.suppressions:report_objects=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer" ASAN_OPTIONS="detect_leaks=1:check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer"
compile_flags: --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --dbg=on --opt=on --allocator=system --sanitize=address --ssl --enable-free-mon=on -j$(grep -c ^processor /proc/cpuinfo) --nostrip
multiversion_platform: ubuntu1804
multiversion_edition: enterprise
@@ -12195,10 +12194,8 @@ buildvariants:
- ubuntu1804-build
stepback: true
expansions:
- # We need llvm-symbolizer in the PATH for ASAN for clang-3.7 or later.
- variant_path_suffix: /opt/mongodbtoolchain/v3/bin
lang_environment: LANG=C
- san_options: LSAN_OPTIONS="suppressions=etc/lsan.suppressions:report_objects=1" ASAN_OPTIONS=detect_leaks=1:check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1
+ san_options: LSAN_OPTIONS="suppressions=etc/lsan.suppressions:report_objects=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer" ASAN_OPTIONS="detect_leaks=1:check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer"
compile_flags: --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --opt=on --allocator=system --sanitize=address --ssl -j$(grep -c ^processor /proc/cpuinfo) --nostrip
multiversion_platform: ubuntu1804
multiversion_edition: enterprise
@@ -12222,10 +12219,10 @@ buildvariants:
stepback: false
expansions:
additional_package_targets: archive-mongocryptd archive-mongocryptd-debug
- # We need llvm-symbolizer in the PATH for UBSAN.
- variant_path_suffix: /opt/mongodbtoolchain/v3/bin
lang_environment: LANG=C
- san_options: UBSAN_OPTIONS="print_stacktrace=1"
+ # If you add anything to san_options, make sure the appropriate changes are
+ # also made to SConstruct.
+ san_options: UBSAN_OPTIONS="print_stacktrace=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer"
compile_flags: --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --dbg=on --opt=on --sanitize=undefined --ssl --enable-free-mon=on -j$(grep -c ^processor /proc/cpuinfo) --nostrip
multiversion_platform: ubuntu1804
multiversion_edition: enterprise
@@ -12287,11 +12284,11 @@ buildvariants:
stepback: true
expansions:
additional_package_targets: archive-mongocryptd archive-mongocryptd-debug
- # We need llvm-symbolizer in the PATH for ASAN for clang-3.7 or later.
- variant_path_suffix: /opt/mongodbtoolchain/v3/bin
lang_environment: LANG=C
- san_options: UBSAN_OPTIONS="print_stacktrace=1" LSAN_OPTIONS="suppressions=etc/lsan.suppressions:report_objects=1" ASAN_OPTIONS=detect_leaks=1:check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1
- compile_flags: --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --dbg=on --opt=on --allocator=system --sanitize=undefined,address --ssl -j$(grep -c ^processor /proc/cpuinfo) --nostrip
+ # If you add anything to san_options, make sure the appropriate changes are
+ # also made to SConstruct.
+ san_options: UBSAN_OPTIONS="print_stacktrace=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer" LSAN_OPTIONS="suppressions=etc/lsan.suppressions:report_objects=1" ASAN_OPTIONS="detect_leaks=1:check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer"
+ compile_flags: --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --dbg=on --opt=on --allocator=system --sanitize=undefined,address --ssl -j$(grep -c ^processor /proc/cpuinfo) --nostrip --link-model=dynamic
resmoke_jobs_factor: 0.3 # Avoid starting too many mongod's under {A,UB}SAN build.
hang_analyzer_dump_core: false
scons_cache_scope: shared
@@ -12312,10 +12309,10 @@ buildvariants:
stepback: false
expansions:
additional_package_targets: archive-mongocryptd archive-mongocryptd-debug
- # We need llvm-symbolizer in the PATH for ASAN for clang-3.7 or later.
- variant_path_suffix: /opt/mongodbtoolchain/v3/bin
lang_environment: LANG=C
- san_options: UBSAN_OPTIONS="print_stacktrace=1:halt_on_error=1" LSAN_OPTIONS="suppressions=etc/lsan.suppressions:report_objects=1" ASAN_OPTIONS=detect_leaks=1:check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1
+ # If you add anything to san_options, make sure the appropriate changes are
+ # also made to SConstruct.
+ san_options: UBSAN_OPTIONS="print_stacktrace=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer" LSAN_OPTIONS="suppressions=etc/lsan.suppressions:report_objects=1" ASAN_OPTIONS="detect_leaks=1:check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer"
compile_flags: LINKFLAGS=-nostdlib++ LIBS=stdc++ --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --dbg=on --opt=on --allocator=system --sanitize=undefined,address,fuzzer --ssl -j$(grep -c ^processor /proc/cpuinfo) --nostrip
resmoke_jobs_factor: 0.3 # Avoid starting too many mongod's under {A,UB}SAN build.
hang_analyzer_dump_core: false
diff --git a/etc/scons/mongodbtoolchain_v3_clang.vars b/etc/scons/mongodbtoolchain_v3_clang.vars
index dfa764d940b..3c982be59dd 100644
--- a/etc/scons/mongodbtoolchain_v3_clang.vars
+++ b/etc/scons/mongodbtoolchain_v3_clang.vars
@@ -32,6 +32,7 @@ try:
AR = subprocess.check_output([CXX, '-print-prog-name=ar']).decode('utf-8').strip()
AS = subprocess.check_output([CXX, '-print-prog-name=as']).decode('utf-8').strip()
OBJCOPY = subprocess.check_output([CXX, '-print-prog-name=objcopy']).decode('utf-8').strip()
+ LLVM_SYMBOLIZER = subprocess.check_output([CXX, '-print-prog-name=llvm-symbolizer']).decode('utf-8').strip()
except subprocess.CalledProcessError as e:
print("Failed while invoking toolchain binary " + CXX + ": " + e.output)
SCons.Script.Exit(-1)