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

Parallel actor creation can deadlock or crash riker #122

Closed hardliner66 closed 3 years ago

hardliner66 commented 4 years ago

While implementing one of the benchmarks from actor-framework/benchmarks, I found out that riker sometims deadlocks (hangs) or crashes with an access violation when multiple actors get created simultaneously.

I created a minimal example at my test repo.

The problem seems to be an atomic_load in dashmap, but I'm not sure if this is a bug in dashmap or just misuse on our side.


Tested on:

Additional files: stacktrace.txt

leenozara commented 4 years ago

@xacrimon I wonder if you're able to provide some insight into this?

xacrimon commented 4 years ago

Known bug in rc5, updating to rc6 should solve the issue.

hardliner66 commented 4 years ago

I think I tested with RC6 too. I will retry with an updated version of dashmap and report my findings.

xacrimon commented 4 years ago

This is interesting, it hasn't shown up in any of the intensive multicore tests I've done for rc6.

hardliner66 commented 4 years ago

I locally changed the version to rc6 and the problem still persists: build_and_run.txt

xacrimon commented 4 years ago

I will investigate this issue. Thanks

xacrimon commented 4 years ago

So I got the issue. I am currently doing a major refactor that will fix this but in the meantime switching to dashmap 3.11 should do the trick. There should only be a very tiny amount of self explanatory fixes after the version has been changed in Cargo.toml.

hardliner66 commented 4 years ago

There are some incompatible changes between 4.0 and 3.11; Iter needs more type parameters in 3.11 and the replace method doesn't exist. I looked at replacements (e.g.: delete and insert) but the documented locking behaviour doesn't seem to be a good fit riker.