-
Notifications
You must be signed in to change notification settings - Fork 78
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
bug in monte_carlo example #162
Comments
I had the exactly same problem on Windows 10 / Intel i5-9500 6 core machine.
I suspect that there are some race condition problem somewhere. After running with debugger, I found that UnboundedSender fails at inc_num_messages(): pub fn send(&self, message: T) -> Result<(), SendError<T>> {
if !self.inc_num_messages() {
return Err(SendError(message));
}
self.chan.send(message);
Ok(())
} The only condition that inc_num_messages() returns false is when curr & 1 is 1. I don't understand the meaning of this line. mpsc/chan.rs contains Semaphore impl for bounded and unbounded Semaphores, and unbounded::Semaphore uses 1 to check a closed channel. impl Semaphore for unbounded::Semaphore {
// ...
fn close(&self) {
self.0.fetch_or(1, Release);
}
fn is_closed(&self) -> bool {
self.0.load(Acquire) & 1 == 1
}
} curr & 1 == 1 means is_closed(). Hence, the error comes from cast! on a closed UnboundedSender. Hope this helps. |
Thanks for reporting, it is a small edit which is described in #163. Should be fixed once merged. |
Describe the bug
Monte_carlo example gives me an error like this:
Seems like when child actor ends itself, parent actor ends as well, but there are still several child actors who tries to send messages to their parent
To Reproduce
Steps to reproduce the behavior:
alexromensky@Alexs-MacBook-Pro ractor % cargo run --example monte_carlo
Expected behavior
supposed to run without an error
Additional context
MacOS 13.5.2, rustc 1.72.0 (5680fa18f 2023-08-23)
The text was updated successfully, but these errors were encountered: