-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Lost message when selecing on MPMC in loop from multiple threads #135
Comments
edit: i'm very sorry the formatting of folded code is the way it is I'll add that the program does not exhibit this behavior when I'll provide a simple working example here. This is what a working fn race(receiver: &flume::Receiver<Dropper>, signal: &flume::Receiver<()>) -> bool {
match selector::blocking_select(receiver.recv_async(), signal.recv_async()) {
selector::Either::Left(res) => {
let out = res.is_err();
drop(res);
out
}
selector::Either::Right(_res) => true,
}
} implementation of simple async executor behind fold```rust use std::{ future::Future, pin::Pin, sync::{ atomic::{AtomicBool, Ordering}, Arc, }, task::{Context, Poll, Wake, Waker}, };struct ThreadWaker { impl Wake for ThreadWaker {
} pub(super) enum Either<L, R> { struct Select<F1, F2> {
} struct SelectWaker { impl Wake for SelectWaker {
} impl<F1, F2> Future for Select<F1, F2>
} pub(super) fn blocking_select<Left, Right>( fn block_on(fut: F) -> F::Output
} async fn select<Left, Right>(left: Left, right: Right) -> Either<Left::Output, Right::Output>
}
|
I've put all the demo code in a repo on my forgejo: https://git.asonix.dog/asonix/flume-deadlock |
I have tried to make this example as minimal as I possibly could, but basically this program will hang after a short time on my computer (intel i7 1165g7 + linux 6.6.2 + glibc)
The basic premise is this:
I find that very often, during the first thread reaping cycle, a message that is sent is never dropped, causing the main thread to never progress, even though there still exist threads that are selecting on the channel. I believe this is due to a race in the Selector implementation
without further ado, here's the code:
The text was updated successfully, but these errors were encountered: