You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use tokio::sync::oneshot;asyncfnsome_computation() -> String{"represents the result of the computation".to_string()}#[tokio::main]asyncfnmain(){let(tx, rx) = oneshot::channel();
tokio::spawn(asyncmove{let res = some_computation().await;
tx.send(res).unwrap();});// Do other work while the computation is happening in the background// Wait for the computation resultlet res = rx.await.unwrap();println!("{:?}", res);}
compiled and run with this command:
RUST_LOG=trace RUSTFLAGS="-Z sanitizer=thread" cargo run --target x86_64-unknown-linux-gnu
using rust rustc 1.52.0-nightly (107896c32 2021-03-15)
gave this output: tsan.txt.gz (it's too big to paste here)
I am pretty confident this is due to the thread santizer not understanding Arc's memory barriers. It's also a reason we wrote loom to verify Tokio's concurrency primitives.
Version
1.3.0
Platform
Linux etam-librem.lan 5.11.4-1-default #1 SMP Mon Mar 8 05:16:55 UTC 2021 (be77cd2) x86_64 x86_64 x86_64 GNU/Linux
Description
ThreadSanitizer shows data races when using
oneshot::channel
.Example code (taken from example):
compiled and run with this command:
RUST_LOG=trace RUSTFLAGS="-Z sanitizer=thread" cargo run --target x86_64-unknown-linux-gnu
using rust
rustc 1.52.0-nightly (107896c32 2021-03-15)
gave this output: tsan.txt.gz (it's too big to paste here)
Interesting places pointed in backtraces:
https://github.com/tokio-rs/tokio/blob/tokio-1.3.0/tokio/src/sync/oneshot.rs#L702
https://github.com/tokio-rs/tokio/blob/tokio-1.3.0/tokio/src/sync/oneshot.rs#L324
https://github.com/tokio-rs/tokio/blob/tokio-1.3.0/tokio/src/runtime/blocking/pool.rs#L259-L260
The text was updated successfully, but these errors were encountered: