diff --git a/browser/config/mozconfigs/linux64/tsan b/browser/config/mozconfigs/linux64/tsan index 918c68469625..6149e066f2d9 100644 --- a/browser/config/mozconfigs/linux64/tsan +++ b/browser/config/mozconfigs/linux64/tsan @@ -18,6 +18,9 @@ export MOZ_PKG_SPECIAL=tsan # Disable telemetry ac_add_options MOZ_TELEMETRY_REPORTING= +# Ensure Rust also gets the necessary instrumentation +export RUSTFLAGS="-Zsanitizer=thread" + # rustfmt is currently missing in Rust nightly unset RUSTFMT diff --git a/config/makefiles/rust.mk b/config/makefiles/rust.mk index 8545c3de8b4e..a0f6f81bbddb 100644 --- a/config/makefiles/rust.mk +++ b/config/makefiles/rust.mk @@ -53,11 +53,6 @@ ifeq (1,$(MOZ_PARALLEL_BUILD)) cargo_build_flags += -j1 endif -# This should also be paired with -Zbuild-std, but that doesn't work yet. -ifdef MOZ_TSAN -RUSTFLAGS += -Zsanitizer=thread -endif - # These flags are passed via `cargo rustc` and only apply to the final rustc # invocation (i.e., only the top-level crate, not its dependencies). cargo_rustc_flags = $(CARGO_RUSTCFLAGS) diff --git a/taskcluster/ci/spidermonkey/linux.yml b/taskcluster/ci/spidermonkey/linux.yml index d62e5dde7117..6332c6ca867f 100644 --- a/taskcluster/ci/spidermonkey/linux.yml +++ b/taskcluster/ci/spidermonkey/linux.yml @@ -237,7 +237,7 @@ sm-tsan-linux64/opt: toolchain: - linux64-binutils - linux64-clang - - linux64-rust-nightly + - linux64-rust - linux64-dump-syms sm-rootanalysis-linux64/debug: diff --git a/toolkit/library/gtest/rust/Cargo.toml b/toolkit/library/gtest/rust/Cargo.toml index 5f453ebdff38..e8e4116a9a0e 100644 --- a/toolkit/library/gtest/rust/Cargo.toml +++ b/toolkit/library/gtest/rust/Cargo.toml @@ -35,7 +35,6 @@ glean = ["gkrust-shared/glean", "fog-gtest"] glean_with_gecko = ["gkrust-shared/glean_with_gecko", "fog-gtest"] rust_fxa_client = ["gkrust-shared/rust_fxa_client"] with_dbus = ["gkrust-shared/with_dbus"] -thread_sanitizer = ["gkrust-shared/thread_sanitizer"] [dependencies] bench-collections-gtest = { path = "../../../../xpcom/rust/gtest/bench-collections" } diff --git a/toolkit/library/rust/Cargo.toml b/toolkit/library/rust/Cargo.toml index 880fdf01d5cd..0ab862a586a3 100644 --- a/toolkit/library/rust/Cargo.toml +++ b/toolkit/library/rust/Cargo.toml @@ -36,7 +36,6 @@ glean = ["gkrust-shared/glean"] glean_with_gecko = ["gkrust-shared/glean_with_gecko"] rust_fxa_client = ["gkrust-shared/rust_fxa_client"] with_dbus = ["gkrust-shared/with_dbus"] -thread_sanitizer = ["gkrust-shared/thread_sanitizer"] [dependencies] gkrust-shared = { path = "shared" } diff --git a/toolkit/library/rust/gkrust-features.mozbuild b/toolkit/library/rust/gkrust-features.mozbuild index 5e49dd61992a..8c17a58c8b9d 100644 --- a/toolkit/library/rust/gkrust-features.mozbuild +++ b/toolkit/library/rust/gkrust-features.mozbuild @@ -12,9 +12,6 @@ if CONFIG['MOZ_DEBUG']: 'gecko_refcount_logging', ] -if CONFIG['MOZ_TSAN']: - gkrust_features += ['thread_sanitizer'] - gkrust_features += ['quantum_render', 'webgpu'] if CONFIG['MOZ_WEBRENDER_DEBUGGER']: gkrust_features += ['webrender_debugger'] diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml index 8e3708e41f9d..52278dece930 100644 --- a/toolkit/library/rust/shared/Cargo.toml +++ b/toolkit/library/rust/shared/Cargo.toml @@ -108,7 +108,6 @@ glean = ["fog_control"] glean_with_gecko = ["fog_control/with_gecko"] rust_fxa_client = ["firefox-accounts-bridge"] with_dbus = ["audio_thread_priority/with_dbus"] -thread_sanitizer = ["xpcom/thread_sanitizer"] [lib] path = "lib.rs" diff --git a/xpcom/rust/xpcom/Cargo.toml b/xpcom/rust/xpcom/Cargo.toml index f43f7ec436f7..1cb1e4f8913f 100644 --- a/xpcom/rust/xpcom/Cargo.toml +++ b/xpcom/rust/xpcom/Cargo.toml @@ -11,6 +11,3 @@ nserror = { path = "../nserror" } threadbound = "0.1" xpcom_macros = { path = "xpcom_macros" } thin-vec = { version = "0.2.1", features = ["gecko-ffi"] } - -[features] -thread_sanitizer = [] diff --git a/xpcom/rust/xpcom/src/refptr.rs b/xpcom/rust/xpcom/src/refptr.rs index 52bbe0821648..760a50f2b8fd 100644 --- a/xpcom/rust/xpcom/src/refptr.rs +++ b/xpcom/rust/xpcom/src/refptr.rs @@ -298,18 +298,8 @@ impl AtomicRefcnt { pub unsafe fn dec(&self) -> nsrefcnt { let result = self.0.fetch_sub(1, Ordering::Release) as nsrefcnt - 1; if result == 0 { - // We're going to destroy the object on this thread, so we need - // acquire semantics to synchronize with the memory released by - // the last release on other threads, that is, to ensure that - // writes prior to that release are now visible on this thread. - if cfg!(feature = "thread_sanitizer") { - // TSan doesn't understand atomic::fence, so in order to avoid - // a false positive for every time a refcounted object is - // deleted, we replace the fence with an atomic operation. - self.0.load(Ordering::Acquire); - } else { - atomic::fence(Ordering::Acquire); - } + // We're going to destroy the object on this thread. + atomic::fence(Ordering::Acquire); } result }