-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with AtomicCell containing struct with padding bytes #388
Comments
Thanks for the bug report! Unfortunately, I don't have a Windows machine at hand to reproduce. Could you perhaps try replacing fn main() {
let (tx, rx) = crossbeam_channel::unbounded();
std::thread::spawn(move || {
loop {
tx.send(()).unwrap();
std::thread::sleep(std::time::Duration::from_millis(50));
}
});
let (tx, update_tick) = crossbeam_channel::unbounded();
std::thread::spawn(move || {
loop {
std::thread::sleep(std::time::Duration::from_secs(10));
tx.send(std::time::Instant::now()).unwrap();
}
});
let mut data_i = 0;
loop {
crossbeam_channel::select! {
recv(update_tick) -> tick => {
eprintln!("tick: {:?}", tick);
},
recv(rx) -> data => match data {
Ok(data) => {
data_i += 1;
if data_i % 50== 0 {
dbg!(data_i);
}
std::thread::sleep(std::time::Duration::from_millis(1));
}
Err(_) => break,
},
}
}
} Also, does the deadlock still occur if the tick channel is removed from |
The issue appears to be caused by the On Windows On 64 bit linux, Here is an example that should show the issue on both platforms (debug only, garbage gets optimized away on release): use crossbeam_utils::atomic::AtomicCell;
#[derive(Copy, Clone, Eq, PartialEq)]
struct Object {
a: i64,
b: i32,
}
fn main() {
dbg!();
let cell = AtomicCell::new(Object { a: 0, b: 0 });
let _garbage = [0xfe, 0xfe, 0xfe, 0xfe, 0xfe]; // Needed
let next = Object { a: 0, b: 0 };
loop {
let prev = cell.load();
if cell.compare_exchange(prev, next).is_ok() {
break;
}
}
dbg!();
} |
Looks related to this issue: #315 |
Hotmic uses an outdated version of crossbeam-channel, which depends on a version of crossbeam-utils that has a bug in it's atomic cell implementation (see: crossbeam-rs/crossbeam#388) Hotmic is deprecated in favour of the metrics crate so this commit does an initial migration to that crate.
Bug in windows only code which causes `crossbeam::channel::timer` to deadlock. See: [Issue with AtomicCell containing struct with padding bytes](crossbeam-rs/crossbeam#388)
Bug in windows only code which causes `crossbeam::channel::timer` to deadlock. See: [Issue with AtomicCell containing struct with padding bytes](crossbeam-rs/crossbeam#388)
Edit: root cause here: #388 (comment)
The following code appears to deadlock on Windows only:
It should print something like:
But I see no further output after
[src/main.rs:22] data_i = 150
when running on Windows. It works fine on Linux.Tested with:
stable-x86_64-pc-windows-msvc
(rustc 1.35.0 (3c235d560 2019-05-20)
).The text was updated successfully, but these errors were encountered: