From 09fe21bb0e97c917db04877631ec71b847746815 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 3 Jun 2020 21:26:39 +0800 Subject: [PATCH] partial Merge #19041: ci: tsan with -stdlib=libc++-10 BACKPORT NOTICE: this PR doesn't actually swithc to libc++ due to multiple CI failures such as linking errors or other ------------------ faf62e6ed0ca45db44c370844c3515eb5a8cda12 ci: Remove unused workaround (MarcoFalke) fa7c8509153bfd2d5b4dcff86ad27dfd73e8788b ci: Install llvm to get llvm symbolizer (MarcoFalke) fa563cef61e8a217c5e8ec059e174afae61087a5 test: Add more tsan suppressions (MarcoFalke) fa0cc02c0a029133f080680ae9186002a144738f ci: Mute depends logs completely (MarcoFalke) fa906bf2988c799765a04c484269f890964ec3ee test: Extend tsan suppressions for clang stdlib (MarcoFalke) fa10d850790bbe52d948659bb1ebbb88fe718065 ci: Use libc++ instead of libstdc++ for tsan (MarcoFalke) fa0d5ee1126a8cff9f30f863eb8f5c78bf57e168 ci: Set halt_on_error=1 for tsan (MarcoFalke) fa2ffe87f794caa74f80c1c2d6e6067ee4849632 ci: Deduplicate DOCKER_EXEC (MarcoFalke) fac2eeeb9d718bdb892eef9adf333ea61ba8f3d0 cirrus: Remove no longer needed install step (MarcoFalke) Pull request description: According to the [ThreadSanitizer docs](https://clang.llvm.org/docs/ThreadSanitizer.html#current-status): > C++11 threading is supported with **llvm libc++**. For example, the thread sanitizer build is currently not checking for double lock of mutexes. Fixes (partially) https://github.com/bitcoin/bitcoin/issues/19038#issuecomment-632138003 ACKs for top commit: practicalswift: ACK faf62e6ed0ca45db44c370844c3515eb5a8cda12 fanquake: ACK faf62e6ed0ca45db44c370844c3515eb5a8cda12 hebasto: ACK faf62e6ed0ca45db44c370844c3515eb5a8cda12, maybe re-organize commits to modify suppressions in a single one? Tree-SHA512: 98ce5154b4736dfb811ffdb6e6f63a7bc25fe50d3b73134404a8f3715ad53626c31f9c8132dbacf85de47b9409f1e17a4399e35f78b1da30b1577167ea2982ad --- .cirrus.yml | 4 ---- .travis.yml | 2 +- ci/dash/build_src.sh | 4 ++-- ci/dash/matrix.sh | 2 +- ci/test/00_setup_env_native_tsan.sh | 7 +++---- ci/test/03_before_install.sh | 4 ---- ci/test/04_install.sh | 14 ++++++-------- ci/test/05_before_script.sh | 4 +++- contrib/containers/ci/Dockerfile | 4 +++- test/sanitizer_suppressions/tsan | 23 +++++++++++++++++++++++ 10 files changed, 42 insertions(+), 26 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 1e4b8303b6..92a85b1d26 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -14,9 +14,5 @@ task: folder: "/tmp/ccache_dir" depends_built_cache: folder: "/tmp/cirrus-ci-build/depends/built" - install_script: - - apt-get update - - apt-get -y install git bash ccache - - ccache --max-size=${CCACHE_SIZE} ci_script: - ./ci/test_run_all.sh diff --git a/.travis.yml b/.travis.yml index 7a9f626f1e..4a734e6ed1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -210,7 +210,7 @@ after_success: FILE_ENV="./ci/test/00_setup_env_native_qt5.sh" # x86_64 Linux (xenial, no depends, only system libs, sanitizers: thread (TSan)) - stage: test - name: 'x86_64 Linux [GOAL: install] [bionic] [no depends, only system libs, sanitizers: thread (TSan), no wallet]' + name: 'x86_64 Linux [GOAL: install] [focal] [depends, sanitizers: thread (TSan), no wallet, no gui]' # Not enough memory on travis machines, so feature_block is excluded for now env: >- TEST_RUNNER_EXTRA="--exclude feature_block" diff --git a/ci/dash/build_src.sh b/ci/dash/build_src.sh index 5b4ad1f039..28da619f9e 100755 --- a/ci/dash/build_src.sh +++ b/ci/dash/build_src.sh @@ -45,11 +45,11 @@ rm -rf build-ci mkdir build-ci cd build-ci -../configure $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false) +bash -c "../configure $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG" || ( cat config.log && false) make distdir VERSION=$BUILD_TARGET cd dashcore-$BUILD_TARGET -./configure $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false) +bash -c "./configure $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG" || ( cat config.log && false) make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL V=1 ; false ) diff --git a/ci/dash/matrix.sh b/ci/dash/matrix.sh index 26dcba42ef..a24609fda2 100755 --- a/ci/dash/matrix.sh +++ b/ci/dash/matrix.sh @@ -13,7 +13,7 @@ source ./ci/test/00_setup_env.sh # Configure sanitizers options export ASAN_OPTIONS="" export LSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/lsan" -export TSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/tsan" +export TSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/tsan:halt_on_error=1" export UBSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/ubsan" if [ "$BUILD_TARGET" = "arm-linux" ]; then diff --git a/ci/test/00_setup_env_native_tsan.sh b/ci/test/00_setup_env_native_tsan.sh index b040ca675d..90c48c509c 100755 --- a/ci/test/00_setup_env_native_tsan.sh +++ b/ci/test/00_setup_env_native_tsan.sh @@ -7,13 +7,12 @@ export LC_ALL=C.UTF-8 export CONTAINER_NAME=ci_native_tsan -export PACKAGES="clang-15 llvm-15 python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-filesystem-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev" -export DEP_OPTS="NO_UPNP=1 DEBUG=1" +export PACKAGES="clang llvm libc++abi-dev libc++-dev python3-zmq" +export DEP_OPTS="CC=clang-15 CXX='clang++-15 -stdlib=libc++" export TEST_RUNNER_EXTRA="--extended --exclude feature_pruning,feature_dbcrash,wallet_multiwallet.py" # Temporarily suppress ASan heap-use-after-free (see issue #14163) export TEST_RUNNER_EXTRA="${TEST_RUNNER_EXTRA} --timeout-factor=4" # Increase timeout because sanitizers slow down export GOAL="install" -export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --with-sanitizers=thread" -export BITCOIN_CONFIG="${BITCOIN_CONFIG} CC=clang-15 CXX=clang++-15 CXXFLAGS=-Werror=thread-safety" +export BITCOIN_CONFIG="--enable-zmq --disable-wallet --with-gui=no --with-sanitizers=thread CC=clang-15 CXX=clang++-15" export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG" export PYZMQ=true export RUN_SYMBOL_TESTS=false diff --git a/ci/test/03_before_install.sh b/ci/test/03_before_install.sh index e939b9eeeb..80806aab75 100755 --- a/ci/test/03_before_install.sh +++ b/ci/test/03_before_install.sh @@ -6,10 +6,6 @@ export LC_ALL=C.UTF-8 -# Add llvm-symbolizer directory to PATH. Needed to get symbolized stack traces from the sanitizers. -PATH=$PATH:/usr/lib/llvm-6.0/bin/ -export PATH - BEGIN_FOLD () { echo "" CURRENT_FOLD_NAME=$1 diff --git a/ci/test/04_install.sh b/ci/test/04_install.sh index e5dbb3ebe7..b89fa16f22 100755 --- a/ci/test/04_install.sh +++ b/ci/test/04_install.sh @@ -23,7 +23,7 @@ mkdir -p "${PREVIOUS_RELEASES_DIR}" export ASAN_OPTIONS="detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1" export LSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/lsan" -export TSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/tsan" +export TSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/tsan:halt_on_error=1" export UBSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" env | grep -E '^(BASE_|QEMU_|CCACHE_|LC_ALL|BOOST_TEST_RANDOM|DEBIAN_FRONTEND|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS|PREVIOUS_RELEASES_DIR))' | tee /tmp/env if [[ $HOST = *-mingw32 ]]; then @@ -47,16 +47,14 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then --env-file /tmp/env \ --name $CONTAINER_NAME \ $DOCKER_NAME_TAG) - - DOCKER_EXEC () { - docker exec $DOCKER_ID bash -c "export PATH=$BASE_SCRATCH_DIR/bins/:\$PATH && cd $P_CI_DIR && $*" - } + export DOCKER_CI_CMD_PREFIX="docker exec $DOCKER_ID" else echo "Running on host system without docker wrapper" - DOCKER_EXEC () { - bash -c "export PATH=$BASE_SCRATCH_DIR/bins/:\$PATH && cd $P_CI_DIR && $*" - } fi + +DOCKER_EXEC () { + $DOCKER_CI_CMD_PREFIX bash -c "export PATH=$BASE_SCRATCH_DIR/bins/:\$PATH && cd $P_CI_DIR && $*" +} export -f DOCKER_EXEC if [ -n "$DPKG_ADD_ARCH" ]; then diff --git a/ci/test/05_before_script.sh b/ci/test/05_before_script.sh index 2e56c926b7..e481a06166 100755 --- a/ci/test/05_before_script.sh +++ b/ci/test/05_before_script.sh @@ -33,7 +33,9 @@ if [ -z "$NO_DEPENDS" ]; then else SHELL_OPTS="CONFIG_SHELL=" fi - DOCKER_EXEC $SHELL_OPTS make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS + # Temporary workaround for https://github.com/bitcoin/bitcoin/issues/16368 + python3 -c 'import time; [print(".") or time.sleep(500) for _ in range(4)]' & + ( DOCKER_EXEC $SHELL_OPTS make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS ) &> /dev/null fi if [ -n "$PREVIOUS_RELEASES_TO_DOWNLOAD" ]; then BEGIN_FOLD previous-versions diff --git a/contrib/containers/ci/Dockerfile b/contrib/containers/ci/Dockerfile index 08926c4a2a..0e300f9f23 100644 --- a/contrib/containers/ci/Dockerfile +++ b/contrib/containers/ci/Dockerfile @@ -25,9 +25,11 @@ RUN apt-get update && apt-get install $APT_ARGS \ ccache \ clang \ cmake \ - git \ g++ \ gettext \ + git \ + libc++-dev \ + libc++abi-dev \ libtool \ libxcb-icccm4 \ libxcb-image0 \ diff --git a/test/sanitizer_suppressions/tsan b/test/sanitizer_suppressions/tsan index 73982b87f5..82c7b3f933 100644 --- a/test/sanitizer_suppressions/tsan +++ b/test/sanitizer_suppressions/tsan @@ -9,6 +9,29 @@ race:zmq::* # race (TODO fix) race:validation_chainstatemanager_tests +# double locks (TODO fix) +mutex:g_genesis_wait_mutex +mutex:Interrupt +mutex:CThreadInterrupt +mutex:CConnman::Interrupt +mutex:CConnman::WakeMessageHandler +mutex:CConnman::ThreadOpenConnections +mutex:CConnman::ThreadOpenAddedConnections +mutex:CConnman::SocketHandler +mutex:UpdateTip +mutex:PeerLogicValidation::UpdatedBlockTip +# race (TODO fix) +race:CConnman::WakeMessageHandler +race:CConnman::ThreadMessageHandler +race:fHaveGenesis +race:ProcessNewBlock +race:ThreadImport +race:zmq::* +race:bitcoin-qt +# deadlock (TODO fix) +deadlock:CConnman::ForNode +deadlock:UpdateTip + # WalletBatch (unidentified deadlock) deadlock:WalletBatch