Skip to content

Commit

Permalink
races.md: data race -> race condition to violate memory safety
Browse files Browse the repository at this point in the history
The first example shows that you "can't violate memory safety with safe
Rust" and the second example shows that you "can violate memory safety
with unsafe Rust".

The second example does not demonstrate a data race since there is only
one thread touching `data`.
  • Loading branch information
Enselic committed Dec 5, 2024
1 parent 0674321 commit 6855d3a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/races.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ thread::spawn(move || {
println!("{}", data[idx.load(Ordering::SeqCst)]);
```

We can cause a data race if we instead do the bound check in advance, and then
unsafely access the data with an unchecked value:
We can cause a race condition to violate memory safety if we instead do the bound
check in advance, and then unsafely access the data with an unchecked value:

```rust,no_run
use std::thread;
Expand Down

0 comments on commit 6855d3a

Please sign in to comment.