From 6855d3a7e196f9e418b4b9468189aae4a242fc45 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Thu, 5 Dec 2024 20:17:47 +0100 Subject: [PATCH] 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`. --- src/races.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/races.md b/src/races.md index aaeaf5ba..6f8b9a3c 100644 --- a/src/races.md +++ b/src/races.md @@ -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;