File tree 7 files changed +71
-20
lines changed
7 files changed +71
-20
lines changed Original file line number Diff line number Diff line change @@ -108,12 +108,23 @@ jobs:
108
108
- name : clippy
109
109
run : ./ci/clippy.sh
110
110
111
+ # Run sanitizers.
112
+ san :
113
+ name : san
114
+ runs-on : ubuntu-latest
115
+ steps :
116
+ - uses : actions/checkout@v2
117
+ - name : Install Rust
118
+ run : rustup update nightly && rustup default nightly
119
+ - name : Run sanitizers
120
+ run : ./ci/san.sh
121
+
111
122
# Run loom tests.
112
123
loom :
113
124
name : loom
114
125
runs-on : ubuntu-latest
115
126
steps :
116
- - uses : actions/checkout@master
127
+ - uses : actions/checkout@v2
117
128
- name : Install Rust
118
129
run : rustup update stable && rustup default stable
119
130
- name : loom
@@ -145,6 +156,7 @@ jobs:
145
156
- dependencies
146
157
- rustfmt
147
158
- clippy
159
+ - san
148
160
- loom
149
161
- docs
150
162
runs-on : ubuntu-latest
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ cd " $( dirname " $0 " ) " /..
4
+ set -ex
5
+
6
+ if [[ " $OSTYPE " != " linux" * ]]; then
7
+ exit 0
8
+ fi
9
+
10
+ rustup component add rust-src
11
+
12
+ # Run address sanitizer
13
+ # https://github.com/crossbeam-rs/crossbeam/issues/614
14
+ export ASAN_OPTIONS=" detect_leaks=0"
15
+ cargo clean
16
+ # TODO: Once `cfg(sanitize = "..")` is stable, replace
17
+ # `cfg(crossbeam_sanitize)` with `cfg(sanitize = "..")` and remove
18
+ # `--cfg crossbeam_sanitize`.
19
+ RUSTFLAGS=" -Dwarnings -Zsanitizer=address --cfg crossbeam_sanitize" \
20
+ cargo test --all --release --target x86_64-unknown-linux-gnu --tests --exclude benchmarks -- --test-threads=1
21
+
22
+ cargo clean
23
+ RUSTFLAGS=" -Dwarnings -Zsanitizer=address --cfg crossbeam_sanitize" \
24
+ cargo run \
25
+ --release \
26
+ --target x86_64-unknown-linux-gnu \
27
+ --features nightly \
28
+ --example sanitize \
29
+ --manifest-path crossbeam-epoch/Cargo.toml
30
+
31
+ # Run memory sanitizer
32
+ cargo clean
33
+ RUSTFLAGS=" -Dwarnings -Zsanitizer=memory --cfg crossbeam_sanitize" \
34
+ cargo test -Zbuild-std --all --release --target x86_64-unknown-linux-gnu --tests --exclude benchmarks -- --test-threads=1
35
+
36
+ # Run thread sanitizer
37
+ export TSAN_OPTIONS=" suppressions=$( pwd) /ci/tsan"
38
+ cargo clean
39
+ RUSTFLAGS=" -Dwarnings -Zsanitizer=thread --cfg crossbeam_sanitize" \
40
+ cargo test -Zbuild-std --all --release --target x86_64-unknown-linux-gnu --tests --exclude benchmarks -- --test-threads=1
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export RUSTFLAGS="-D warnings"
8
8
if [[ -n " $TARGET " ]]; then
9
9
# If TARGET is specified, use cross for testing.
10
10
cargo install cross
11
- cross test --all --target " $TARGET " --exclude benchmarks
11
+ cross test --all --target " $TARGET " --exclude benchmarks -- --test-threads=1
12
12
13
13
# For now, the non-host target only runs tests.
14
14
exit 0
@@ -25,22 +25,4 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then
25
25
# Benchmarks are only checked on nightly because depending on unstable features.
26
26
cargo check --all --benches
27
27
cargo check --bins --manifest-path crossbeam-channel/benchmarks/Cargo.toml
28
-
29
- # Run address sanitizer on crossbeam-epoch
30
- # Note: this will be significantly rewritten by https://github.com/crossbeam-rs/crossbeam/pull/591.
31
- if [[ " $OSTYPE " == " linux" * ]]; then
32
- cargo clean
33
-
34
- # TODO: Once `cfg(sanitize = "..")` is stable, replace
35
- # `cfg(crossbeam_sanitize)` with `cfg(sanitize = "..")` and remove
36
- # `--cfg crossbeam_sanitize`.
37
- ASAN_OPTIONS=" detect_odr_violation=0 detect_leaks=0" \
38
- RUSTFLAGS=" -Z sanitizer=address --cfg crossbeam_sanitize" \
39
- cargo run \
40
- --release \
41
- --target x86_64-unknown-linux-gnu \
42
- --features nightly \
43
- --example sanitize \
44
- --manifest-path crossbeam-epoch/Cargo.toml
45
- fi
46
28
fi
Original file line number Diff line number Diff line change
1
+ # TSAN suppressions file for crossbeam
2
+
3
+ # The epoch-based GC uses fences.
4
+ race:crossbeam_epoch
5
+
6
+ # Push and steal operations in crossbeam-deque may cause data races, but such
7
+ # data races are safe. If a data race happens, the value read by `steal` is
8
+ # forgotten and the steal operation is then retried.
9
+ race:crossbeam_deque*push
10
+ race:crossbeam_deque*steal
11
+
12
+ # Non-lock-free AtomicCell uses SeqLock which uses fences.
13
+ race:crossbeam_utils::atomic::atomic_cell::AtomicCell<T>::compare_exchange
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ fn recv() {
127
127
assert_eq ! ( r. try_recv( ) , Err ( TryRecvError :: Empty ) ) ;
128
128
}
129
129
130
+ #[ cfg( not( crossbeam_sanitize) ) ] // TODO: assertions failed due to tsan is slow
130
131
#[ test]
131
132
fn recv_timeout ( ) {
132
133
let start = Instant :: now ( ) ;
@@ -251,6 +252,7 @@ fn select() {
251
252
assert_eq ! ( hits. load( Ordering :: SeqCst ) , 8 ) ;
252
253
}
253
254
255
+ #[ cfg( not( crossbeam_sanitize) ) ] // TODO: assertions failed due to tsan is slow
254
256
#[ test]
255
257
fn ready ( ) {
256
258
const THREADS : usize = 4 ;
Original file line number Diff line number Diff line change @@ -199,6 +199,7 @@ mod tests {
199
199
. unwrap ( ) ;
200
200
}
201
201
202
+ #[ cfg( not( crossbeam_sanitize) ) ] // TODO: assertions failed due to `cfg(crossbeam_sanitize)` reduce `internal::MAX_OBJECTS`
202
203
#[ test]
203
204
fn incremental ( ) {
204
205
const COUNT : usize = 100_000 ;
Original file line number Diff line number Diff line change @@ -375,6 +375,7 @@ pub(crate) struct Local {
375
375
376
376
// Make sure `Local` is less than or equal to 2048 bytes.
377
377
// https://github.com/crossbeam-rs/crossbeam/issues/551
378
+ #[ cfg( not( crossbeam_sanitize) ) ] // `crossbeam_sanitize` reduces the size of `Local`
378
379
#[ test]
379
380
fn local_size ( ) {
380
381
assert ! (
You can’t perform that action at this time.
0 commit comments