Skip to content

Commit

Permalink
clarify situation of non-synchronized differently-sized accesses
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 10, 2024
1 parent 24c19b8 commit e5b0694
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
//!
//! That said, Rust *does* inherit the C++ limitation that non-synchronized atomic accesses may not
//! partially overlap: they must be either disjoint or access the exact same memory. This in
//! particular rules out non-synchronized differently-sized accesses to the same data.
//! particular rules out non-synchronized differently-sized atomic accesses to the same data.
//! (Non-synchronized differently-sized non-atomic read accesses are permitted.)
//!
//! [cpp]: https://en.cppreference.com/w/cpp/atomic
//! [cpp-intro.races]: https://timsong-cpp.github.io/cppwp/n4868/intro.multithread#intro.races
Expand Down
7 changes: 3 additions & 4 deletions src/tools/miri/src/concurrency/data_race.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@ impl AccessType {
}
}

/// Memory Cell vector clock metadata
/// for data-race detection.
/// Per-byte vector clock metadata for data-race detection.
#[derive(Clone, PartialEq, Eq, Debug)]
struct MemoryCellClocks {
/// The vector-clock timestamp and the thread that did the last non-atomic write. We don't need
Expand All @@ -324,8 +323,8 @@ struct MemoryCellClocks {
read: VClock,

/// Atomic access, acquire, release sequence tracking clocks.
/// For non-atomic memory in the common case this
/// value is set to None.
/// For non-atomic memory this value is set to None.
/// For atomic memory, each byte carries this information.
atomic_ops: Option<Box<AtomicMemoryCellClocks>>,
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/fail/data_race/mixed_size_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn convert(a: &AtomicU16) -> &[AtomicU8; 2] {
}

// We can't allow mixed-size accesses; they are not possible in C++ and even
// Intel says you shouldn't do it.
// Intel says you shouldn't do it. Even read-read races are disallowed that way.
fn main() {
let a = AtomicU16::new(0);
let a16 = &a;
Expand Down

0 comments on commit e5b0694

Please sign in to comment.