Skip to content

Issue with AtomicCell containing struct with padding bytes #388

Closed
@mchesser

Description

@mchesser

Edit: root cause here: #388 (comment)


The following code appears to deadlock on Windows only:

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 update_tick = crossbeam_channel::tick(std::time::Duration::from_secs(10));
    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,
            },
        }
    }
}

It should print something like:

[src/main.rs:22] data_i = 50
[src/main.rs:22] data_i = 100
[src/main.rs:22] data_i = 150
tick: Ok(Instant { tv_sec: 1023, tv_nsec: 433738600 })
[src/main.rs:22] data_i = 200
[src/main.rs:22] data_i = 250
[src/main.rs:22] data_i = 300

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)).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions