lunatic-solutions / lunatic

Lunatic is an Erlang-inspired runtime for WebAssembly
https://lunatic.solutions
Apache License 2.0
4.62k stars 138 forks source link

invalid memory reference (signal: 11) when using the new atomic registry API #189

Open bkolobara opened 1 year ago

bkolobara commented 1 year ago

This is a bit of a hard to reproduce bug. You will need to run some tests from https://github.com/lunatic-solutions/lunatic-rs in a loop to trigger it:

while true; do 
    cargo test --test registry
done

I believe the issue is in this unsafe code: https://github.com/lunatic-solutions/lunatic/blob/07454fb4a6657960479386da35d04921a7bd4892/crates/lunatic-registry-api/src/lib.rs#L177-L182

One way to resolve this would be to move the "lookup and insert" operation to the process spawning function. In that case we would not require to hold onto a lock across host-guest-host calls.