riker-rs / riker

Easily build efficient, highly concurrent and resilient applications. An Actor Framework for Rust.
https://riker.rs
MIT License
1.02k stars 69 forks source link

Using an actor name with parentheses causes an abort #120

Closed anacrolix closed 4 years ago

anacrolix commented 4 years ago

I called a Context::actor_of with a name containing ( and ) (I used &format!("{:?}") and determined that it was the () that caused it.

$ cargo run
   Compiling actix v0.1.0 (/Users/anacrolix/src/eratosthenes/rust/riker)
    Finished dev [unoptimized + debuginfo] target(s) in 2.68s
     Running `target/debug/actix`
2020-06-30 04:45:30+00:00 DEBG [riker::system] Starting actor system: System[riker]
2020-06-30 04:45:30+00:00 DEBG [riker::system] Actor system [ea287462-b746-48e2-a584-07db5bfdb1f1] [riker] started
Int(2)

thread 'pool-thread-#10' has overflowed its stack
fatal runtime error: stack overflow
Abort trap: 6
hardliner66 commented 4 years ago

This doesn't only happen when using parens. It also happens when an actor has any invalid name (e.g.: not matching this regex r"^[a-zA-Z0-9_-]+$") or an actor with the same name already exists.

After a bit of digging it seems that the to_string method on CreateError gets called recursively which destroys the stack.

Code to reproduce:

use riker::actors::*;

fn main() {
    let ce = CreateError::InvalidName("asd".to_string());
    println!("{}", ce.to_string());
}
anacrolix commented 4 years ago

@hardliner66 https://github.com/riker-rs/riker/pull/123