Sanitizers (#195)

This commit is contained in:
Mahmut Bulut 2020-04-04 00:33:42 +02:00 committed by GitHub
parent b5408dc912
commit 1edb490b1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 83 additions and 0 deletions

28
.github/workflows/sanitizers.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: Run Sanitizers
on:
push:
branches:
- master
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2020-03-08
override: true
- uses: davidB/rust-cargo-make@v1
with:
version: '0.30.0'
- name: Sanitizers
env:
RUST_BACKTRACE: full
RUST_LOG: 'trace'
run: |
tools/san_harness.sh

30
tools/san_harness.sh Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -eo pipefail
rustup update
rustup toolchain install nightly
if [[ "$OSTYPE" == "darwin"* ]]; then
TARGET_SELECT=''
else
TARGET_SELECT='x86_64-unknown-linux-gnu'
fi
# Run SANs
echo "LSAN"
cargo clean
export RUSTFLAGS="-Z sanitizer=leak"
cargo +nightly build --examples --target ${TARGET_SELECT}
sudo -E target/${TARGET_SELECT}/debug/examples/parallel_computation
sudo -E target/${TARGET_SELECT}/debug/examples/callbacks
# -------------------------------
echo "TSAN"
cargo clean
export RUSTFLAGS="-Z sanitizer=thread"
export TSAN_OPTIONS=suppressions=../../../../tools/tsan.suppressions
cargo +nightly build --examples --target ${TARGET_SELECT}
sudo -E target/${TARGET_SELECT}/debug/examples/parallel_computation
sudo -E target/${TARGET_SELECT}/debug/examples/send_recv
sudo -E target/${TARGET_SELECT}/debug/examples/callbacks

25
tools/tsan.suppressions Normal file
View File

@ -0,0 +1,25 @@
# Anything comes from dynamic affinity pinner and load balancer of
# Bastion doesn't need concrete guarantees. They are not that crucial.
race:bastion_executor::blocking
# There is a bug for this. There is a dangling ref in the drop.
# Read more about it here: https://github.com/rust-lang/rust/issues/55005
race:Arc*drop
race:Condvar::*
race:std::sync::mpsc
# Races of drop for the Receiver guard
race:crossbeam_channel::counter::Receiver
# OpenSSL FFI
race:CRYPTO_THREAD*
race:OPENSSL_*
# Data races of mimalloc
race:mi*
race:_mi*
# lazy_static and thread_local has barriers which are not
# picked-up by TSAN. Like Lazy<T> and Local<T>.
race:lazy_static
race:std::thread::local