Skip to content

Commit

Permalink
Replace sanitize feature with cfg(crossbeam_sanitize)
Browse files Browse the repository at this point in the history
Feature flag can be accidentally enabled by --all-features, so use cfg
instead.
  • Loading branch information
taiki-e committed Jan 4, 2021
1 parent d6ab297 commit dcdf02b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions ci/crossbeam-epoch-loom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
cd "$(dirname "$0")"/../crossbeam-epoch
set -ex

export RUSTFLAGS="-D warnings --cfg=loom_crossbeam"
export RUSTFLAGS="-D warnings --cfg loom_crossbeam --cfg crossbeam_sanitize"

# With MAX_PREEMPTIONS=2 the loom tests (currently) take around 11m.
# If we were to run with =3, they would take several times that,
# which is probably too costly for CI.
env LOOM_MAX_PREEMPTIONS=2 cargo test --test loom --features sanitize --release -- --nocapture
env LOOM_MAX_PREEMPTIONS=2 cargo test --test loom --release -- --nocapture
9 changes: 6 additions & 3 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then
cargo check --all --benches
cd crossbeam-channel/benchmarks
cargo check --bins
cd ..
cd ../..

# Run address sanitizer on crossbeam-epoch
# Note: this will be significantly rewritten by https://github.com/crossbeam-rs/crossbeam/pull/591.
if [[ "$OSTYPE" == "linux"* ]]; then
cd crossbeam-epoch
cargo clean

# TODO: Once `cfg(sanitize = "..")` is stable, replace
# `cfg(crossbeam_sanitize)` with `cfg(sanitize = "..")` and remove
# `--cfg crossbeam_sanitize`.
ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0" \
RUSTFLAGS="-Z sanitizer=address" \
RUSTFLAGS="-Z sanitizer=address --cfg crossbeam_sanitize" \
cargo run \
--release \
--target x86_64-unknown-linux-gnu \
--features sanitize,nightly \
--features nightly \
--example sanitize

cd ..
Expand Down
3 changes: 0 additions & 3 deletions crossbeam-epoch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ alloc = []
# of crossbeam may make breaking changes to them at any time.
nightly = ["crossbeam-utils/nightly", "const_fn"]

# TODO: docs
sanitize = [] # Makes it more likely to trigger any potential data races.

[dependencies]
cfg-if = "1"
const_fn = { version = "0.4.4", optional = true }
Expand Down
10 changes: 5 additions & 5 deletions crossbeam-epoch/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ use crate::sync::list::{Entry, IsElement, IterError, List};
use crate::sync::queue::Queue;

/// Maximum number of objects a bag can contain.
#[cfg(not(feature = "sanitize"))]
#[cfg(not(crossbeam_sanitize))]
const MAX_OBJECTS: usize = 62;
#[cfg(feature = "sanitize")]
#[cfg(crossbeam_sanitize)]
const MAX_OBJECTS: usize = 4;

/// A bag of deferred functions.
Expand Down Expand Up @@ -109,7 +109,7 @@ impl Default for Bag {
#[rustfmt::skip]
fn default() -> Self {
// TODO: [no_op; MAX_OBJECTS] syntax blocked by https://github.com/rust-lang/rust/issues/49147
#[cfg(not(feature = "sanitize"))]
#[cfg(not(crossbeam_sanitize))]
return Bag {
len: 0,
deferreds: [
Expand Down Expand Up @@ -177,7 +177,7 @@ impl Default for Bag {
Deferred::new(no_op_func),
],
};
#[cfg(feature = "sanitize")]
#[cfg(crossbeam_sanitize)]
return Bag {
len: 0,
deferreds: [
Expand Down Expand Up @@ -278,7 +278,7 @@ impl Global {
pub(crate) fn collect(&self, guard: &Guard) {
let global_epoch = self.try_advance(guard);

let steps = if cfg!(feature = "sanitize") {
let steps = if cfg!(crossbeam_sanitize) {
usize::max_value()
} else {
Self::COLLECT_STEPS
Expand Down

0 comments on commit dcdf02b

Please sign in to comment.