From ebd3bf25909cb20dc1224872be3017397579ff0f Mon Sep 17 00:00:00 2001 From: practicalswift Date: Sun, 25 Nov 2018 21:23:30 +0100 Subject: [PATCH 1/3] Make test p2p_invalid_messages.py pass: Allow for expected Travis ASAN memory increase --- .travis/test_04_install.sh | 2 +- test/functional/p2p_invalid_messages.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis/test_04_install.sh b/.travis/test_04_install.sh index 75de71c583..94d9ccb32d 100755 --- a/.travis/test_04_install.sh +++ b/.travis/test_04_install.sh @@ -9,7 +9,7 @@ export LC_ALL=C.UTF-8 travis_retry docker pull "$DOCKER_NAME_TAG" export TSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/tsan" export UBSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1" -env | grep -E '^(CCACHE_|WINEDEBUG|LC_ALL|BOOST_TEST_RANDOM|CONFIG_SHELL|(TSAN|UBSAN)_OPTIONS)' | tee /tmp/env +env | grep -E '^(BITCOIN_CONFIG|CCACHE_|WINEDEBUG|LC_ALL|BOOST_TEST_RANDOM|CONFIG_SHELL|(TSAN|UBSAN)_OPTIONS)' | tee /tmp/env if [[ $HOST = *-mingw32 ]]; then DOCKER_ADMIN="--cap-add SYS_ADMIN" fi diff --git a/test/functional/p2p_invalid_messages.py b/test/functional/p2p_invalid_messages.py index 3ee67980a4..65997a5f9d 100755 --- a/test/functional/p2p_invalid_messages.py +++ b/test/functional/p2p_invalid_messages.py @@ -3,6 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test node responses to invalid network messages.""" +import os import struct from test_framework import messages @@ -66,7 +67,10 @@ class InvalidMessagesTest(BitcoinTestFramework): msg_at_size = msg_unrecognized("b" * valid_data_limit) assert len(msg_at_size.serialize()) == msg_limit - with node.assert_memory_usage_stable(increase_allowed=0.5): + increase_allowed = 0.5 + if [s for s in os.environ.get("BITCOIN_CONFIG", "").split(" ") if "--with-sanitizers" in s and "address" in s]: + increase_allowed = 3.5 + with node.assert_memory_usage_stable(increase_allowed=increase_allowed): self.log.info( "Sending a bunch of large, junk messages to test " "memory exhaustion. May take a bit...") From ff7212ec326bb0851eac3653cdb03551d3aab659 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Thu, 15 Nov 2018 15:08:28 +0100 Subject: [PATCH 2/3] Add ASan Travis build --- .travis.yml | 7 ++++--- .travis/test_04_install.sh | 4 +++- .travis/test_06_script.sh | 2 +- test/sanitizer_suppressions/lsan | 7 +++++++ 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 test/sanitizer_suppressions/lsan diff --git a/.travis.yml b/.travis.yml index cd691e49cf..217108c6aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -92,7 +92,7 @@ jobs: DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1 ALLOW_HOST_PACKAGES=1" GOAL="install" BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-glibc-back-compat --enable-reduce-exports --enable-debug CXXFLAGS=\"-g0 -O2\"" -# x86_64 Linux (xenial, no depends, only system libs, sanitizers: thread (TSAN)) +# x86_64 Linux (xenial, no depends, only system libs, sanitizers: thread (TSan)) - stage: test env: >- HOST=x86_64-unknown-linux-gnu @@ -102,14 +102,15 @@ jobs: RUN_FUNCTIONAL_TESTS=false # Disabled for now. TODO identify suppressions or exclude specific tests GOAL="install" BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER --with-sanitizers=thread --disable-hardening --disable-asm CC=clang CXX=clang++" -# x86_64 Linux (no depends, only system libs, sanitizers: undefined (UBSAN) + integer) +# x86_64 Linux (no depends, only system libs, sanitizers: address/leak (ASan + LSan) + undefined (UBSan) + integer) - stage: test env: >- HOST=x86_64-unknown-linux-gnu PACKAGES="clang llvm python3-zmq qtbase5-dev qttools5-dev-tools libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev" NO_DEPENDS=1 + FUNCTIONAL_TESTS_CONFIG="--exclude wallet_multiwallet.py" # Temporarily suppress ASan heap-use-after-free (see issue #14163) GOAL="install" - BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER --with-sanitizers=integer,undefined CC=clang CXX=clang++" + BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER --with-sanitizers=address,integer,undefined CC=clang CXX=clang++" # x86_64 Linux, No wallet - stage: test env: >- diff --git a/.travis/test_04_install.sh b/.travis/test_04_install.sh index 94d9ccb32d..03a61ea9f8 100755 --- a/.travis/test_04_install.sh +++ b/.travis/test_04_install.sh @@ -7,9 +7,11 @@ export LC_ALL=C.UTF-8 travis_retry docker pull "$DOCKER_NAME_TAG" +export ASAN_OPTIONS="" +export LSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/lsan" export TSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/tsan" export UBSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1" -env | grep -E '^(BITCOIN_CONFIG|CCACHE_|WINEDEBUG|LC_ALL|BOOST_TEST_RANDOM|CONFIG_SHELL|(TSAN|UBSAN)_OPTIONS)' | tee /tmp/env +env | grep -E '^(BITCOIN_CONFIG|CCACHE_|WINEDEBUG|LC_ALL|BOOST_TEST_RANDOM|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS)' | tee /tmp/env if [[ $HOST = *-mingw32 ]]; then DOCKER_ADMIN="--cap-add SYS_ADMIN" fi diff --git a/.travis/test_06_script.sh b/.travis/test_06_script.sh index 62d58ecf4d..506d2b518c 100755 --- a/.travis/test_06_script.sh +++ b/.travis/test_06_script.sh @@ -56,6 +56,6 @@ fi if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then BEGIN_FOLD functional-tests - DOCKER_EXEC test/functional/test_runner.py --ci --combinedlogslen=4000 --coverage --quiet --failfast ${extended} + DOCKER_EXEC test/functional/test_runner.py --ci --combinedlogslen=4000 --coverage --quiet --failfast ${extended} ${FUNCTIONAL_TESTS_CONFIG} END_FOLD fi diff --git a/test/sanitizer_suppressions/lsan b/test/sanitizer_suppressions/lsan new file mode 100644 index 0000000000..568f574495 --- /dev/null +++ b/test/sanitizer_suppressions/lsan @@ -0,0 +1,7 @@ +leak:addCoin +leak:libcrypto +leak:libqminimal +leak:libQt5Core +leak:libQt5Gui +leak:libQt5Widgets +leak:new_allocator.h From 6541d59ddc2b1b475187e6cbe76a50ee6e85b421 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Mon, 26 Nov 2018 22:06:59 +0100 Subject: [PATCH 3/3] Add LSan suppression warnings --- test/sanitizer_suppressions/lsan | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/sanitizer_suppressions/lsan b/test/sanitizer_suppressions/lsan index 568f574495..57bc2c2bea 100644 --- a/test/sanitizer_suppressions/lsan +++ b/test/sanitizer_suppressions/lsan @@ -1,7 +1,10 @@ +# Suppress warnings about addCoin(...) leak in the CoinSelection benchmark leak:addCoin +leak:bench_bitcoin + +# Suppress warnings triggered in dependencies leak:libcrypto leak:libqminimal leak:libQt5Core leak:libQt5Gui leak:libQt5Widgets -leak:new_allocator.h