diff --git a/ci/script.sh b/ci/script.sh index 5bf4a8b07bd7d6ed509ba8af7f6e97236ef3372d..c988b65063c5d92d736524e8c1455ef2bdbcd14b 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -7,7 +7,9 @@ main() { ;; x86_64-unknown-linux-gnu) cargo check --target $TARGET + cargo test --target $TARGET + cargo test --target $TARGET --release export TSAN_OPTIONS="suppressions=$(pwd)/blacklist.txt" export RUSTFLAGS="-Z sanitizer=thread" diff --git a/src/ring_buffer/mod.rs b/src/ring_buffer/mod.rs index 8311a5554a115cb30a17742df50f3583292c6c4d..321af205b1e39bf405875fafe416d57e354ab908 100644 --- a/src/ring_buffer/mod.rs +++ b/src/ring_buffer/mod.rs @@ -28,6 +28,7 @@ where // this is where we enqueue new items #[cfg(target_has_atomic = "ptr")] tail: AtomicUsize, #[cfg(not(target_has_atomic = "ptr"))] tail: usize, + buffer: UntaggedOption<A>, } diff --git a/src/ring_buffer/spsc.rs b/src/ring_buffer/spsc.rs index b31ef0fbdcade1a310c78de3cd0da30978f453c9..05e44357d66520be630f423e9a8566a62f137fae 100644 --- a/src/ring_buffer/spsc.rs +++ b/src/ring_buffer/spsc.rs @@ -144,8 +144,7 @@ where // NOTE(volatile) the value of `head` can change at any time in the execution context of the // producer so we inform this to the compiler using a volatile load if next_tail != unsafe { ptr::read_volatile(&rb.head) } { - // NOTE(ptr::write) the memory slot that we are about to write to is uninitialized. We - // use `ptr::write` to avoid running `T`'s destructor on the uninitialized memory + // NOTE(ptr::write) see the other `enqueue` implementation above for details unsafe { ptr::write(buffer.get_unchecked_mut(rb.tail), item) } rb.tail = next_tail; Ok(())