-
Notifications
You must be signed in to change notification settings - Fork 643
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
"there is no reactor running" panic when system is quickly dropped #531
Comments
Hi there! I'm encountering the same problem. As an additional detail I could add that the same crash happen when use actix::prelude::*;
struct MyActor;
impl Actor for MyActor {
type Context = Context<Self>;
fn started(&mut self, ctx: &mut Self::Context) {
tokio::runtime::Handle::current(); // will be paniced
}
}
fn main() {
let system = actix::System::new();
system.block_on(async {
MyActor.start();
// Next line fixes panic when uncommented:
// tokio::task::yield_now().await;
});
} |
I believe this is caused by the actix/actix/src/contextimpl.rs Lines 219 to 232 in d7aab0a
The poll will call your The |
Here is code that reproduces the issue:
main.rs
Cargo.toml
Expected Behavior
The program does not panic. Nothing should be sent to stdout, as system is dropped before 100 milliseconds pass (interval).
Current Behavior
The program panics and produces the following backtrace on crash:
Possible Solution
I suspect
run_interval
creates some task that isn't dropped in time or it always assumes tokio runtime exists. I noticed that a short sleep just after staring the actor fixes the issue (commented in the example). Explicitctx.cancel_future
instopping
orstopped
method does not fix the problem.Steps to Reproduce (for bugs)
run_interval
in actor'sstarted
method.Context
We came across this error twice. Once when running a test function with
should_panic
attribute. It looks like the expected panic triggers drops and the drop of the system causes this panic. Another case was starting and dropping a system in a loop in a fuzz test.Your Environment
Linux work 5.16.13-200.fc35.x86_64 #1 SMP PREEMPT Tue Mar 8 22:50:58 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
rustc -V
): rustc 1.58.1 (db9d1b20b 2022-01-20)The text was updated successfully, but these errors were encountered: