summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2016-04-09 14:39:15 -0400
committerAndrew Morrow <acm@mongodb.com>2016-04-19 10:09:30 -0400
commitf2ec414e9c21f09fe7e5009efe00a8934743c0db (patch)
treeb0e6399da1a06d9d11c36a958eba11ce5358b364
parentaf65f9793a212fdeffeeebed3a76b11921e53032 (diff)
downloadmongo-f2ec414e9c21f09fe7e5009efe00a8934743c0db.tar.gz
SERVER-16221 Enable UBSAN build and unittest
-rw-r--r--SConstruct15
-rw-r--r--etc/evergreen.yml35
-rw-r--r--etc/ubsan.blacklist7
-rw-r--r--src/mongo/db/storage/wiredtiger/SConscript82
-rw-r--r--src/mongo/s/SConscript1
-rw-r--r--src/mongo/s/catalog/replset/SConscript1
6 files changed, 95 insertions, 46 deletions
diff --git a/SConstruct b/SConstruct
index bdbe8124a8c..29ead390c3a 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1,4 +1,5 @@
# -*- mode: python; -*-
+import atexit
import copy
import datetime
import errno
@@ -24,6 +25,12 @@ import libdeps
EnsureSConsVersion( 2, 3, 0 )
+def print_build_failures():
+ from SCons.Script import GetBuildFailures
+ for bf in GetBuildFailures():
+ print "%s failed: %s" % (bf.node, bf.errstr)
+atexit.register(print_build_failures)
+
def versiontuple(v):
return tuple(map(int, (v.split("."))))
@@ -2149,9 +2156,15 @@ def doConfigure(myenv):
tsan_options += "suppressions=\"%s\" " % myenv.File("#etc/tsan.suppressions").abspath
myenv['ENV']['TSAN_OPTIONS'] = tsan_options
- # By default, undefined behavior sanitizer doesn't stop on the first error. Make it so.
if using_ubsan:
+ # By default, undefined behavior sanitizer doesn't stop on the first error. Make it so.
AddToCCFLAGSIfSupported(myenv, "-fno-sanitize-recover")
+ # We don't currently target any architectures that require
+ # strict alignment, and we definitely have alignment
+ # issues in both the MMAPv1 and WT storage engines. We
+ # don't want to need to fix those errors before making
+ # UBSAN available.
+ AddToCCFLAGSIfSupported(myenv, "-fno-sanitize=alignment")
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 e062bebd53e..2636b9464c2 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -298,7 +298,7 @@ functions:
extra_args="$extra_args --continueOnFailure"
fi
- ${path_prefix} ${asan_symbolizer} ${enable_lsan} ${rlp_environment} ${python|python} buildscripts/resmoke.py ${resmoke_args} $extra_args ${test_flags} --log=buildlogger --reportFile=report.json
+ ${path_prefix} ${san_symbolizer} ${san_options} ${rlp_environment} ${python|python} buildscripts/resmoke.py ${resmoke_args} $extra_args ${test_flags} --log=buildlogger --reportFile=report.json
"run jstestfuzz":
- command: shell.exec
@@ -1697,7 +1697,7 @@ tasks:
cp mongodb*/bin/* .
mkdir -p snmpconf
cp -f src/mongo/db/modules/enterprise/docs/mongod.conf.master snmpconf/mongod.conf
- SNMPCONFPATH=snmpconf ${asan_symbolizer} ${enable_lsan} ${python|python} buildscripts/resmoke.py --suites=snmp --jobs ${num_jobs_available|1} --shuffle --storageEngine=mmapv1 ${test_flags} --log=buildlogger --reportFile=report.json
+ SNMPCONFPATH=snmpconf ${san_symbolizer} ${san_options} ${python|python} buildscripts/resmoke.py --suites=snmp --jobs ${num_jobs_available|1} --shuffle --storageEngine=mmapv1 ${test_flags} --log=buildlogger --reportFile=report.json
- <<: *task_template
name: snmp_WT
@@ -1714,7 +1714,7 @@ tasks:
cp mongodb*/bin/* .
mkdir -p snmpconf
cp -f src/mongo/db/modules/enterprise/docs/mongod.conf.master snmpconf/mongod.conf
- SNMPCONFPATH=snmpconf ${asan_symbolizer} ${enable_lsan} ${python|python} buildscripts/resmoke.py --suites=snmp --jobs ${num_jobs_available|1} --shuffle --storageEngine=wiredTiger ${test_flags} --log=buildlogger --reportFile=report.json
+ SNMPCONFPATH=snmpconf ${san_symbolizer} ${san_options} ${python|python} buildscripts/resmoke.py --suites=snmp --jobs ${num_jobs_available|1} --shuffle --storageEngine=wiredTiger ${test_flags} --log=buildlogger --reportFile=report.json
- <<: *task_template
name: ssl
@@ -5773,8 +5773,8 @@ buildvariants:
batchtime: 1440 # 1 day
expansions:
tooltags: "-tags 'ssl'"
- asan_symbolizer: ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.5
- enable_lsan: LSAN_OPTIONS="suppressions=etc/lsan.suppressions" ASAN_OPTIONS=detect_leaks=1
+ san_symbolizer: ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.5
+ san_options: LSAN_OPTIONS="suppressions=etc/lsan.suppressions" ASAN_OPTIONS=detect_leaks=1
compile_flags: CC=/usr/bin/clang CXX=/usr/bin/clang++ --dbg=on --opt=on --allocator=system --sanitize=address --ssl -j$(grep -c ^processor /proc/cpuinfo) --nostrip VARIANT_DIR=build
num_jobs_available: $(grep -c ^processor /proc/cpuinfo)
test_flags: -j1 # Avoid starting too many mongod's under ASAN build.
@@ -5895,8 +5895,8 @@ buildvariants:
batchtime: 1440 # 1 day
expansions:
tooltags: "-tags 'ssl'"
- asan_symbolizer: ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.5
- enable_lsan: LSAN_OPTIONS="suppressions=etc/lsan.suppressions" ASAN_OPTIONS=detect_leaks=1
+ san_symbolizer: ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.5
+ san_options: LSAN_OPTIONS="suppressions=etc/lsan.suppressions" ASAN_OPTIONS=detect_leaks=1
compile_flags: CC=/usr/bin/clang CXX=/usr/bin/clang++ --opt=on --allocator=system --sanitize=address --ssl -j$(grep -c ^processor /proc/cpuinfo) --nostrip VARIANT_DIR=build
num_jobs_available: $(grep -c ^processor /proc/cpuinfo)
test_flags: -j1 # Avoid starting too many mongod's under ASAN build.
@@ -5910,6 +5910,27 @@ buildvariants:
- name: jstestfuzz_sharded_WT
- name: unittests
+- name: debian81-debug-ubsan
+ display_name: ~ UBSAN Enterprise Debian 8.1 DEBUG
+ modules:
+ - enterprise
+ run_on:
+ - debian81-test
+ stepback: true
+ batchtime: 1440 # 1 day
+ expansions:
+ gorootvars: GOROOT=/opt/go PATH="/opt/go/bin:$PATH"
+ tooltags: "-tags 'ssl sasl'"
+ san_symbolizer: UBSAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.5
+ san_options: UBSAN_OPTIONS="print_stacktrace=1"
+ compile_flags: CC=/usr/bin/clang CXX=/usr/bin/clang++ --dbg=on --opt=on --allocator=system --sanitize=undefined --ssl -j$(grep -c ^processor /proc/cpuinfo) --nostrip CXXFLAGS="-nostdlib -nostdinc++" LIBPATH=/opt/mongodbtoolchain/v2/lib/gcc/x86_64-mongodb-linux/5.3.0 CPPPATH="/opt/mongodbtoolchain/v2/include/c++/5.3.0/ /opt/mongodbtoolchain/v2/include/c++/5.3.0/x86_64-mongodb-linux" CPPDEFINES="_GLIBCXX_USE_CXX11_ABI=0" VARIANT_DIR=build
+ num_jobs_available: $(grep -c ^processor /proc/cpuinfo)
+ tasks:
+ - name: compile
+ distros:
+ - debian81-build
+ - name: unittests
+
- name: ubuntu1410-fast-clang
display_name: ~ Clang/libc++ SSL Ubuntu 14.10
run_on:
diff --git a/etc/ubsan.blacklist b/etc/ubsan.blacklist
index 72e14191f6a..12996682507 100644
--- a/etc/ubsan.blacklist
+++ b/etc/ubsan.blacklist
@@ -14,8 +14,9 @@ src:src/third_party/unicode-*/*
src:src/third_party/yaml-cpp-*/*
src:src/third_party/zlib-*/*
-# See https://jira.mongodb.org/browse/WT-2402
-src:src/third_party/wiredtiger/*
+# See SERVER-22705. We depend on the C flexible array trick
+# which trips up UBSAN.
+src:src/mongo/db/storage/mmap_v1/*
# See SERVER-23713. The pipeline arith expressions and accumulators need
# to be re-written to avoid undefined behavior.
@@ -33,3 +34,5 @@ fun:_ZStanSt13_Ios_FmtflagsS_
# Maybe https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734 or similar
fun:_ZNSt8_Rb_tree*_M_get_insert_hint_unique_posESt23*
fun:_ZNSt8_Rb_tree*_M_insert_I*
+# Maybe https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63345 or similar
+fun:_ZNSt8_Rb_tree*_M_insert_nodeE*
diff --git a/src/mongo/db/storage/wiredtiger/SConscript b/src/mongo/db/storage/wiredtiger/SConscript
index 431a89a5703..20d170ac8a5 100644
--- a/src/mongo/db/storage/wiredtiger/SConscript
+++ b/src/mongo/db/storage/wiredtiger/SConscript
@@ -1,5 +1,11 @@
Import("env")
Import("wiredtiger")
+Import("get_option")
+
+using_ubsan = False
+sanitizer_list = get_option('sanitize')
+if sanitizer_list:
+ using_ubsan = 'undefined' in sanitizer_list.split(',')
env.Library(
target='storage_wiredtiger_customization_hooks',
@@ -92,26 +98,6 @@ if wiredtiger:
)
wtEnv.CppUnitTest(
- target='storage_wiredtiger_record_store_test',
- source=['wiredtiger_record_store_test.cpp',
- ],
- LIBDEPS=[
- 'storage_wiredtiger_mock',
- '$BUILD_DIR/mongo/db/storage/record_store_test_harness',
- ],
- )
-
- wtEnv.CppUnitTest(
- target='storage_wiredtiger_index_test',
- source=['wiredtiger_index_test.cpp',
- ],
- LIBDEPS=[
- 'storage_wiredtiger_mock',
- '$BUILD_DIR/mongo/db/storage/sorted_data_interface_test_harness',
- ],
- )
-
- wtEnv.CppUnitTest(
target='storage_wiredtiger_init_test',
source=['wiredtiger_init_test.cpp',
],
@@ -122,22 +108,46 @@ if wiredtiger:
NO_CRUTCH=True,
)
- wtEnv.CppUnitTest(
- target='storage_wiredtiger_kv_engine_test',
- source=['wiredtiger_kv_engine_test.cpp',
+ # All of these tests fail to compile under undefined behavior
+ # sanitizer due to unexpressed circular dependency edges. In particualr
+ # they all need a definition from the 'catalog'.
+ if not using_ubsan:
+ wtEnv.CppUnitTest(
+ target='storage_wiredtiger_record_store_test',
+ source=['wiredtiger_record_store_test.cpp',
+ ],
+ LIBDEPS=[
+ 'storage_wiredtiger_mock',
+ '$BUILD_DIR/mongo/db/storage/record_store_test_harness',
],
- LIBDEPS=[
- 'storage_wiredtiger_mock',
- '$BUILD_DIR/mongo/db/storage/kv/kv_engine_test_harness',
- ],
- )
+ )
- wtEnv.CppUnitTest(
- target='storage_wiredtiger_util_test',
- source=['wiredtiger_util_test.cpp',
+ wtEnv.CppUnitTest(
+ target='storage_wiredtiger_index_test',
+ source=['wiredtiger_index_test.cpp',
+ ],
+ LIBDEPS=[
+ 'storage_wiredtiger_mock',
+ '$BUILD_DIR/mongo/db/storage/sorted_data_interface_test_harness',
],
- LIBDEPS=[
- '$BUILD_DIR/mongo/db/service_context',
- 'storage_wiredtiger_mock',
- ],
- )
+ )
+
+ wtEnv.CppUnitTest(
+ target='storage_wiredtiger_kv_engine_test',
+ source=['wiredtiger_kv_engine_test.cpp',
+ ],
+ LIBDEPS=[
+ 'storage_wiredtiger_mock',
+ '$BUILD_DIR/mongo/db/storage/kv/kv_engine_test_harness',
+ ],
+ )
+
+ wtEnv.CppUnitTest(
+ target='storage_wiredtiger_util_test',
+ source=['wiredtiger_util_test.cpp',
+ ],
+ LIBDEPS=[
+ '$BUILD_DIR/mongo/db/service_context',
+ 'storage_wiredtiger_mock',
+ ],
+ )
diff --git a/src/mongo/s/SConscript b/src/mongo/s/SConscript
index 71ba6bdacac..20ea510e4c0 100644
--- a/src/mongo/s/SConscript
+++ b/src/mongo/s/SConscript
@@ -250,6 +250,7 @@ env.Library(
"d_state.cpp",
],
LIBDEPS=[
+ "$BUILD_DIR/mongo/db/commands/core",
"$BUILD_DIR/mongo/db/concurrency/lock_manager",
"$BUILD_DIR/mongo/db/query/query",
"$BUILD_DIR/mongo/db/range_deleter",
diff --git a/src/mongo/s/catalog/replset/SConscript b/src/mongo/s/catalog/replset/SConscript
index 4dbf05af852..9d05a072dca 100644
--- a/src/mongo/s/catalog/replset/SConscript
+++ b/src/mongo/s/catalog/replset/SConscript
@@ -67,6 +67,7 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/db/repl/read_concern_args',
+ '$BUILD_DIR/mongo/executor/network_interface',
'$BUILD_DIR/mongo/s/catalog/dist_lock_manager',
'$BUILD_DIR/mongo/s/client/sharding_client',
],