Closed as not planned
Description
openedon Aug 30, 2022
I tried this code:
use std::sync::{Arc, RwLock};
use std::thread::spawn;
fn main() {
let count = 2;
let data = Arc::new(RwLock::new(vec![Some(true); count]));
for i in 0..count {
let data = data.clone();
Some(spawn(move || {
data.write().unwrap()[i] = None;
}));
}
// This hangs a lot, since 1.62.0 (1.61 works fine)
while data.read().unwrap()[0].is_some()
|| data.read().unwrap()[1].is_some()
{}
// This always passes
while data.read().unwrap()[0].is_some() {}
while data.read().unwrap()[1].is_some() {}
dbg!();
}
I expected to see this happen: print [src/main.rs:25]
Instead, this happened: but it hangs
Meta
rustc --version --verbose
:
rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-unknown-linux-gnu
release: 1.63.0
LLVM version: 14.0.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment