Skip to content

Commit

Permalink
Merge #14794: tests: Add AddressSanitizer (ASan) Travis build
Browse files Browse the repository at this point in the history
6541d59 Add LSan suppression warnings (practicalswift)
ff7212e Add ASan Travis build (practicalswift)
ebd3bf2 Make test p2p_invalid_messages.py pass: Allow for expected Travis ASAN memory increase (practicalswift)

Pull request description:

  Add ASan Travis build.

Tree-SHA512: b9712aaf0c9112b637b6ef0c5d93961863dcbecaf31d9561eb09258a61540fb31d2c8ecae86518a82763279e4aa6cac266cd352c2b2507df0335c0199f8b3d78
  • Loading branch information
MarcoFalke committed Nov 27, 2018
2 parents fdf146f + 6541d59 commit 600b85b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Expand Up @@ -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
Expand All @@ -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: >-
Expand Down
4 changes: 3 additions & 1 deletion .travis/test_04_install.sh
Expand Up @@ -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 '^(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
Expand Down
2 changes: 1 addition & 1 deletion .travis/test_06_script.sh
Expand Up @@ -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
6 changes: 5 additions & 1 deletion test/functional/p2p_invalid_messages.py
Expand Up @@ -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
Expand Down Expand Up @@ -66,7 +67,10 @@ def run_test(self):
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...")
Expand Down
10 changes: 10 additions & 0 deletions test/sanitizer_suppressions/lsan
@@ -0,0 +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

0 comments on commit 600b85b

Please sign in to comment.