Skip to content

Commit 20ed5d5

Browse files
Ryan EgesdahlEvergreen Agent
authored andcommitted
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.
1 parent 29ec081 commit 20ed5d5

File tree

3 files changed

+31
-44
lines changed

3 files changed

+31
-44
lines changed

SConstruct

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,6 @@ add_option('sanitize-coverage',
273273
metavar='cov1,cov2,...covN',
274274
)
275275

276-
add_option('llvm-symbolizer',
277-
default='llvm-symbolizer',
278-
help='name of (or path to) the LLVM symbolizer',
279-
)
280-
281276
add_option('allocator',
282277
choices=["auto", "system", "tcmalloc", "tcmalloc-experimental"],
283278
default="auto",
@@ -790,6 +785,9 @@ env_vars.Add('LINKFLAGS',
790785
help='Sets flags for the linker',
791786
converter=variable_shlex_converter)
792787

788+
env_vars.Add('LLVM_SYMBOLIZER',
789+
help='Name of or path to the LLVM symbolizer')
790+
793791
env_vars.Add('MAXLINELENGTH',
794792
help='Maximum line length before using temp files',
795793
# This is very small, but appears to be the least upper bound
@@ -2917,21 +2915,20 @@ def doConfigure(myenv):
29172915
LINKFLAGS="${SANITIZER_BLACKLIST_GENERATOR}",
29182916
)
29192917

2920-
llvm_symbolizer = get_option('llvm-symbolizer')
2921-
if os.path.isabs(llvm_symbolizer):
2918+
symbolizer_option = ""
2919+
if env['LLVM_SYMBOLIZER']:
2920+
llvm_symbolizer = env['LLVM_SYMBOLIZER']
2921+
2922+
if not os.path.isabs(llvm_symbolizer):
2923+
llvm_symbolizer = myenv.WhereIs(llvm_symbolizer)
2924+
29222925
if not myenv.File(llvm_symbolizer).exists():
2923-
print("WARNING: Specified symbolizer '%s' not found" % llvm_symbolizer)
2924-
llvm_symbolizer = None
2925-
else:
2926-
llvm_symbolizer = myenv.WhereIs(llvm_symbolizer)
2926+
myenv.FatalError(f"Symbolizer binary at path {llvm_symbolizer} does not exist")
2927+
2928+
symbolizer_option = f":external_symbolizer_path=\"{llvm_symbolizer}\""
29272929

2928-
tsan_options = ""
2929-
if llvm_symbolizer:
2930-
myenv['ENV']['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer
2931-
myenv['ENV']['LSAN_SYMBOLIZER_PATH'] = llvm_symbolizer
2932-
tsan_options = "external_symbolizer_path=\"%s\" " % llvm_symbolizer
2933-
elif using_asan:
2934-
myenv.FatalError("Using the address sanitizer requires a valid symbolizer")
2930+
elif using_asan or using_tsan or using_ubsan:
2931+
myenv.FatalError("The address, thread, and undefined behavior sanitizers require llvm-symbolizer for meaningful reports")
29352932

29362933
if using_asan:
29372934
# Unfortunately, abseil requires that we make these macros
@@ -2943,10 +2940,10 @@ def doConfigure(myenv):
29432940
# If anything is changed, added, or removed in either asan_options or
29442941
# lsan_options, be sure to make the corresponding changes to the
29452942
# appropriate build variants in etc/evergreen.yml
2946-
asan_options = "check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1"
2947-
lsan_options = "detect_leaks=1:report_objects=1:suppressions=%s" % myenv.File("#etc/lsan.suppressions").abspath
2948-
env['ENV']['ASAN_OPTIONS'] = asan_options
2949-
env['ENV']['LSAN_OPTIONS'] = lsan_options
2943+
asan_options = "detect_leaks=1:check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1"
2944+
lsan_options = f"report_objects=1:suppressions={myenv.File('#etc/lsan.suppressions').abspath}"
2945+
env['ENV']['ASAN_OPTIONS'] = asan_options + symbolizer_option
2946+
env['ENV']['LSAN_OPTIONS'] = lsan_options + symbolizer_option
29502947

29512948
if using_tsan:
29522949

@@ -2975,8 +2972,8 @@ def doConfigure(myenv):
29752972
# reporting thread leaks, which we have because we don't
29762973
# do a clean shutdown of the ServiceContext.
29772974
#
2978-
tsan_options += "halt_on_error=1:report_thread_leaks=0:die_after_fork=0:suppressions=\"%s\" " % myenv.File("#etc/tsan.suppressions").abspath
2979-
myenv['ENV']['TSAN_OPTIONS'] = tsan_options
2975+
tsan_options = f"halt_on_error=1:report_thread_leaks=0:die_after_fork=0:suppressions={myenv.File('#etc/tsan.suppressions').abspath}"
2976+
myenv['ENV']['TSAN_OPTIONS'] = tsan_options + symbolizer_option
29802977
myenv.AppendUnique(CPPDEFINES=['THREAD_SANITIZER'])
29812978

29822979
if using_ubsan:
@@ -2992,7 +2989,7 @@ def doConfigure(myenv):
29922989
# sure to make the corresponding changes to the appropriate build
29932990
# variants in etc/evergreen.yml
29942991
ubsan_options = "print_stacktrace=1"
2995-
myenv['ENV']['UBSAN_OPTIONS'] = ubsan_options
2992+
myenv['ENV']['UBSAN_OPTIONS'] = ubsan_options + symbolizer_option
29962993

29972994
if myenv.ToolchainIs('msvc') and optBuild:
29982995
# http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx

etc/evergreen.yml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,6 @@ functions:
14571457
${gcov_environment} \
14581458
${lang_environment} \
14591459
${san_options} \
1460-
${san_symbolizer} \
14611460
${snmp_config_path} \
14621461
${resmoke_wrapper} \
14631462
$python buildscripts/resmoke.py run \
@@ -12225,12 +12224,10 @@ buildvariants:
1222512224
stepback: false
1222612225
expansions:
1222712226
additional_package_targets: archive-mongocryptd archive-mongocryptd-debug
12228-
# We need llvm-symbolizer in the PATH for ASAN for clang-3.7 or later.
12229-
variant_path_suffix: /opt/mongodbtoolchain/v3/bin
1223012227
lang_environment: LANG=C
1223112228
# If you add anything to san_options, make sure the appropriate changes are
1223212229
# also made to SConstruct.
12233-
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
12230+
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"
1223412231
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)
1223512232
multiversion_platform: ubuntu1804
1223612233
multiversion_edition: enterprise
@@ -12294,10 +12291,8 @@ buildvariants:
1229412291
- ubuntu1804-build
1229512292
stepback: true
1229612293
expansions:
12297-
# We need llvm-symbolizer in the PATH for ASAN for clang-3.7 or later.
12298-
variant_path_suffix: /opt/mongodbtoolchain/v3/bin
1229912294
lang_environment: LANG=C
12300-
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
12295+
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"
1230112296
compile_flags: --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --opt=on --allocator=system --sanitize=address --ssl -j$(grep -c ^processor /proc/cpuinfo)
1230212297
multiversion_platform: ubuntu1804
1230312298
multiversion_edition: enterprise
@@ -12321,12 +12316,10 @@ buildvariants:
1232112316
stepback: false
1232212317
expansions:
1232312318
additional_package_targets: archive-mongocryptd archive-mongocryptd-debug
12324-
# We need llvm-symbolizer in the PATH for UBSAN.
12325-
variant_path_suffix: /opt/mongodbtoolchain/v3/bin
1232612319
lang_environment: LANG=C
1232712320
# If you add anything to san_options, make sure the appropriate changes are
1232812321
# also made to SConstruct.
12329-
san_options: UBSAN_OPTIONS="print_stacktrace=1"
12322+
san_options: UBSAN_OPTIONS="print_stacktrace=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer"
1233012323
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)
1233112324
multiversion_platform: ubuntu1804
1233212325
multiversion_edition: enterprise
@@ -12388,10 +12381,10 @@ buildvariants:
1238812381
stepback: true
1238912382
expansions:
1239012383
additional_package_targets: archive-mongocryptd archive-mongocryptd-debug
12391-
# We need llvm-symbolizer in the PATH for ASAN for clang-3.7 or later.
12392-
variant_path_suffix: /opt/mongodbtoolchain/v3/bin
1239312384
lang_environment: LANG=C
12394-
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
12385+
# If you add anything to san_options, make sure the appropriate changes are
12386+
# also made to SConstruct.
12387+
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"
1239512388
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) --link-model=dynamic
1239612389
resmoke_jobs_factor: 0.3 # Avoid starting too many mongod's under {A,UB}SAN build.
1239712390
hang_analyzer_dump_core: false
@@ -12421,12 +12414,10 @@ buildvariants:
1242112414
stepback: false
1242212415
expansions:
1242312416
additional_package_targets: archive-mongocryptd archive-mongocryptd-debug
12424-
# We need llvm-symbolizer in the PATH for ASAN for clang-3.7 or later.
12425-
variant_path_suffix: /opt/mongodbtoolchain/v3/bin
1242612417
lang_environment: LANG=C
1242712418
# If you add anything to san_options, make sure the appropriate changes are
1242812419
# also made to SConstruct.
12429-
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
12420+
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"
1243012421
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)
1243112422
resmoke_jobs_factor: 0.3 # Avoid starting too many mongod's under {A,UB}SAN build.
1243212423
hang_analyzer_dump_core: false
@@ -12445,8 +12436,6 @@ buildvariants:
1244512436
stepback: false
1244612437
expansions:
1244712438
additional_package_targets: archive-mongocryptd archive-mongocryptd-debug
12448-
# We need llvm-symbolizer in the PATH for ASAN for clang-3.7 or later.
12449-
variant_path_suffix: /opt/mongodbtoolchain/v3/bin
1245012439
lang_environment: LANG=C
1245112440
# If you add anything to san_options, make sure the appropriate
1245212441
# changes are also made to SConstruct.
@@ -12459,7 +12448,7 @@ buildvariants:
1245912448
# thread leaks, which we have because we don't do a clean shutdown
1246012449
# of the ServiceContext.
1246112450
#
12462-
san_options: TSAN_OPTIONS="halt_on_error=1:report_thread_leaks=0:die_after_fork=0:suppressions=etc/tsan.suppressions"
12451+
san_options: TSAN_OPTIONS="halt_on_error=1:report_thread_leaks=0:die_after_fork=0:suppressions=etc/tsan.suppressions:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer"
1246312452
# TODO: Remove some of the excluded tags when the ephemeralForTest storage engine is
1246412453
# further along in development: https://jira.mongodb.org/browse/SERVER-48325
1246512454
test_flags: --storageEngine=ephemeralForTest --majorityReadConcern=off --excludeWithAnyTags=requires_persistence,requires_journaling,uses_transactions,requires_wiredtiger,requires_snapshot_read,requires_majority_read_concern

etc/scons/mongodbtoolchain_v3_clang.vars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ try:
3232
AR = subprocess.check_output([CXX, '-print-prog-name=ar']).decode('utf-8').strip()
3333
AS = subprocess.check_output([CXX, '-print-prog-name=as']).decode('utf-8').strip()
3434
OBJCOPY = subprocess.check_output([CXX, '-print-prog-name=objcopy']).decode('utf-8').strip()
35+
LLVM_SYMBOLIZER = subprocess.check_output([CXX, '-print-prog-name=llvm-symbolizer']).decode('utf-8').strip()
3536
except subprocess.CalledProcessError as e:
3637
print("Failed while invoking toolchain binary " + CXX + ": " + e.output)
3738
SCons.Script.Exit(-1)

0 commit comments

Comments
 (0)