Skip to content

MPMC queue deadlocks #17

@ghost

Description

The following code deadlocks on my machine. You might have to run several times to hit the bug.

extern crate crossbeam;
extern crate multiqueue;

fn main() {
    const MESSAGES: usize = 1_000_000;
    const THREADS: usize = 2;

    let (tx, rx) = multiqueue::mpmc_queue(MESSAGES as u64);

    crossbeam::scope(|s| {
        for _ in 0..THREADS {
            let tx = tx.clone();
            s.spawn(move || {
                for _ in 0..MESSAGES / THREADS {
                    while tx.try_send(()).is_err() {}
                }
            });
        }
        for _ in 0..THREADS {
            let rx = rx.clone();
            s.spawn(move || {
                for _ in 0..MESSAGES / THREADS {
                    rx.recv().unwrap();
                }
            });
        }
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions