From 32ea8281b394a0bb4c75e41eb3cce4465b2a9284 Mon Sep 17 00:00:00 2001 From: Carl Lerche <me@carllerche.com> Date: Fri, 25 May 2018 12:40:37 -0700 Subject: [PATCH] Use sanitizers in CI (#204) --- .travis.yml | 18 ++++++++++++++++++ ci/tsan | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 ci/tsan diff --git a/.travis.yml b/.travis.yml index 8600e8f..dbc744e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,6 +42,24 @@ matrix: - rustup target add wasm32-unknown-unknown - cargo build --target=wasm32-unknown-unknown + # Sanitizers + - rust: nightly + os: linux + script: + - | + set -e + + export RUST_TEST_THREADS=1 + export ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0" + export TSAN_OPTIONS="suppressions=`pwd`/ci/tsan" + + # Run address sanitizer + RUSTFLAGS="-Z sanitizer=address" \ + cargo test --tests --target x86_64-unknown-linux-gnu + + # Run thread sanitizer + RUSTFLAGS="-Z sanitizer=thread" \ + cargo test --tests --target x86_64-unknown-linux-gnu before_install: set -e diff --git a/ci/tsan b/ci/tsan new file mode 100644 index 0000000..34f76ab --- /dev/null +++ b/ci/tsan @@ -0,0 +1,17 @@ +# TSAN suppressions file for `bytes` + +# TSAN does not understand fences and `Arc::drop` is implemented using a fence. +# This causes many false positives. +race:Arc*drop +race:arc*Weak*drop + +# `std` mpsc is not used in any Bytes code base. This race is triggered by some +# rust runtime logic. +race:std*mpsc_queue + +# Probably more fences in std. +race:__call_tls_dtors + +# `is_inline` is explicitly called concurrently without synchronization. The +# safety explanation can be found in a comment. +race:Inner::is_inline -- GitLab