multiqueue icon indicating copy to clipboard operation
multiqueue copied to clipboard

MPMC queue deadlocks

Open ghost opened this issue 7 years ago • 4 comments

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();
                }
            });
        }
    });
}

ghost avatar Aug 15 '17 11:08 ghost

thanks, pulling this out of hibernation so will look at it. Fixing some bugs I never got around to and that may reveal the cause of this

schets avatar Oct 25 '17 01:10 schets

hey - was wondering: did you ever make headway on this? just ran it with the current version and encountered a deadlock. I spent a few minutes trying to discern what was happening but couldn't make heads or tails of it. Even if it can't be fixed immediately, it'd be nice to know what part of the code triggered the condition, if known. Thanks!

jonathanstrong avatar Feb 28 '18 07:02 jonathanstrong

There is at least one bug with the current implementation, I'm working out a whether this directly competes with my current job before I do any future work though

schets avatar Mar 02 '18 23:03 schets

I believe this is occurring with Tokio: https://stackoverflow.com/questions/53711246/tokio-with-multiqueue-sometimes-hangs-sometimes-works

rivertam avatar Dec 10 '18 21:12 rivertam