races.md: data race -> race condition to violate memory safety

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`.
pull/470/head
Martin Nordholts 3 months ago
parent 0674321898
commit 6855d3a7e1

@ -60,8 +60,8 @@ thread::spawn(move || {
println!("{}", data[idx.load(Ordering::SeqCst)]); println!("{}", data[idx.load(Ordering::SeqCst)]);
``` ```
We can cause a data race if we instead do the bound check in advance, and then We can cause a race condition to violate memory safety if we instead do the bound
unsafely access the data with an unchecked value: check in advance, and then unsafely access the data with an unchecked value:
```rust,no_run ```rust,no_run
use std::thread; use std::thread;

Loading…
Cancel
Save