slawlor / ractor

Rust actor framework
MIT License
1.31k stars 68 forks source link

Bidirectional linking can cause stack overflow on actor shutdown #167

Closed slawlor closed 9 months ago

slawlor commented 9 months ago

Discussed in https://github.com/slawlor/ractor/discussions/166

Before starting this discussion, I had already conducted tests. Here is how I tested it:

sampler.get_cell().link(proc.get_cell());
proc.get_cell().link(sampler.get_cell());
concurrency::sleep(concurrency::Duration::from_secs(3)).await;
// sampler.stop(Some("user shutdown".to_owned()));
proc.stop(Some("user shutdown".to_owned()));

However, during runtime, it crashed with the following error message: "thread 'tokio-runtime-worker' has overflowed its stack, fatal runtime error: stack overflow". Did I use the link method incorrectly?