Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ci/tsan
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# TSAN suppressions file for crossbeam

# The epoch-based GC uses fences.
race:crossbeam_epoch

# Push and steal operations in crossbeam-deque may cause data races, but such
# data races are safe. If a data race happens, the value read by `steal` is
# forgotten and the steal operation is then retried.
Expand Down
13 changes: 13 additions & 0 deletions crossbeam-epoch/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// The rustc-cfg emitted by the build script are *not* public API.

use std::env;

fn main() {
println!("cargo:rerun-if-changed=build.rs");

// `cfg(sanitize = "..")` is not stabilized.
let sanitize = env::var("CARGO_CFG_SANITIZE").unwrap_or_default();
if sanitize.contains("thread") {
println!("cargo:rustc-cfg=crossbeam_sanitize_thread");
}
}
10 changes: 9 additions & 1 deletion crossbeam-epoch/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,18 @@ impl Global {
if local_epoch.is_pinned() && local_epoch.unpinned() != global_epoch {
return global_epoch;
}

// TODO: This is stronger than the actual one because the fence is only emitted
// if the loop is not early exited.
if cfg!(crossbeam_sanitize_thread) {
local.epoch.load(Ordering::Acquire);
}
}
}
}
atomic::fence(Ordering::Acquire);
if !cfg!(crossbeam_sanitize_thread) {
atomic::fence(Ordering::Acquire);
}

// All pinned participants were pinned in the current global epoch.
// Now let's advance the global epoch...
Expand Down