summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2020-07-13 17:04:30 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-15 00:12:06 +0000
commitf07b26628c8aaa9cbd68cbeb096c08c778c8c4a8 (patch)
tree568f73a3c0eb654511cca4b7d116f8fcb0e0e0f0
parent01dd381f3359c44bbc9338d91371d1ff823bb7d8 (diff)
downloadmongo-f07b26628c8aaa9cbd68cbeb096c08c778c8c4a8.tar.gz
SERVER-49078 Disable libunwind for TSAN
-rw-r--r--SConstruct14
-rw-r--r--etc/evergreen.yml2
-rw-r--r--etc/tsan.suppressions1
-rw-r--r--src/mongo/util/stacktrace.h16
-rw-r--r--src/mongo/util/stacktrace_posix.cpp10
5 files changed, 27 insertions, 16 deletions
diff --git a/SConstruct b/SConstruct
index e1dc9255b93..0f47acf5684 100644
--- a/SConstruct
+++ b/SConstruct
@@ -2917,6 +2917,20 @@ def doConfigure(myenv):
myenv.AppendUnique(CPPDEFINES=['ADDRESS_SANITIZER'])
if using_tsan:
+
+ 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")
+
# die_after_fork=0 is a temporary setting to allow tests to continue while we figure out why
# we're running afoul of it. If we remove it here, it also needs to be removed from the test
# variant in etc/evergreen.yml
diff --git a/etc/evergreen.yml b/etc/evergreen.yml
index cc8d08ac676..f02812dcccc 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -12186,7 +12186,7 @@ buildvariants:
# TODO: Remove some of the excluded tags when the Biggie storage engine is
# further along in development: https://jira.mongodb.org/browse/SERVER-48325
test_flags: --storageEngine=biggie --excludeWithAnyTags=requires_persistence,requires_journaling,uses_transactions,requires_wiredtiger,requires_snapshot_read
- compile_flags: --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --dbg=on --opt=on --allocator=system --sanitize=thread --ssl --enable-free-mon=on -j$(grep -c ^processor /proc/cpuinfo)
+ compile_flags: --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --dbg=on --opt=on --allocator=system --sanitize=thread --ssl --enable-free-mon=on --use-libunwind=off -j$(grep -c ^processor /proc/cpuinfo)
# Avoid starting too many mongod's under TSAN build.
resmoke_jobs_factor: 0.3
scons_cache_scope: shared
diff --git a/etc/tsan.suppressions b/etc/tsan.suppressions
index 08da28be651..f02173b5799 100644
--- a/etc/tsan.suppressions
+++ b/etc/tsan.suppressions
@@ -23,3 +23,4 @@ race:src/third_party/wiredtiger/*
# handlers.
signal:abruptQuitAction
signal:abruptQuitWithAddrSignal
+signal:StackTraceSigAltStackTest::tryHandler
diff --git a/src/mongo/util/stacktrace.h b/src/mongo/util/stacktrace.h
index 4cc1ed688b6..e36a0aea03b 100644
--- a/src/mongo/util/stacktrace.h
+++ b/src/mongo/util/stacktrace.h
@@ -40,10 +40,6 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/config.h"
-#if !defined(__has_feature)
-#define __has_feature(x) 0
-#endif
-
/**
* All-thread backtrace is only implemented on Linux. Even on Linux, it's only AS-safe
* when we are using the libunwind backtrace implementation. The feature and related
@@ -51,20 +47,10 @@
* - setupStackTraceSignalAction
* - markAsStackTraceProcessingThread
* - printAllThreadStacks
- *
- * This feature currently does not work with TSAN because TSAN introduces internal
- * threads which block SIGUSR2, and that violates our assumption that all threads
- * are known and accept SIGUSR2. With this enabled, users could try getting a
- * stack trace and get a segfault instead. For the time being, we are disabling
- * this feature with TSAN. However, this feature will need to be fixed to work with
- * TSAN so developers can diagnose TSAN test failures with on-demand stack traces.
- * TODO: https://jira.mongodb.org/browse/SERVER-48622
*/
-#if defined(__linux__)
-#if defined(MONGO_CONFIG_USE_LIBUNWIND) && !__has_feature(thread_sanitizer)
+#if defined(__linux__) && defined(MONGO_CONFIG_USE_LIBUNWIND)
#define MONGO_STACKTRACE_CAN_DUMP_ALL_THREADS
#endif
-#endif
namespace mongo {
diff --git a/src/mongo/util/stacktrace_posix.cpp b/src/mongo/util/stacktrace_posix.cpp
index 3ad87711037..7b888f16c80 100644
--- a/src/mongo/util/stacktrace_posix.cpp
+++ b/src/mongo/util/stacktrace_posix.cpp
@@ -56,6 +56,16 @@
#define MONGO_STACKTRACE_BACKEND_EXECINFO 2
#if defined(MONGO_CONFIG_USE_LIBUNWIND)
+
+#if !defined(__has_feature)
+#define __has_feature(x) 0
+#endif
+
+#if __has_feature(thread_sanitizer)
+// TODO: SERVER-48622 (and see also https://github.com/google/sanitizers/issues/943)
+#error "Cannot currently use libunwind with -fsanitize=thread"
+#endif
+
#define MONGO_STACKTRACE_BACKEND MONGO_STACKTRACE_BACKEND_LIBUNWIND
#elif defined(MONGO_CONFIG_HAVE_EXECINFO_BACKTRACE)
#define MONGO_STACKTRACE_BACKEND MONGO_STACKTRACE_BACKEND_EXECINFO