You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Causing a host function to be called in parallel leads to aliased mutable references to the function's Env. This is a data race and is undefined behavior.
Thanks for the report! I've made a PR which keeps the Env mutable by default but synchronizes it.
This fixes the problem but is not an optimal solution, we'll want a &Env version too, probably. And possibly a &mut Env when used in a single threaded context if we can make the trait constraints for that work...
Open to feedback on this, I'll probably start writing up a design doc later today.
Describe the bug
Causing a host function to be called in parallel leads to aliased mutable references to the function's
Env
. This is a data race and is undefined behavior.Here's a complete example:
Running with
wasmer-1.0.0-alpha02.0
andcargo run --release
gives me this output on Linux:There's a pretty clear data race here—the correct output would be
Steps to reproduce
Run the above example with
cargo run --release
Expected behavior
This looks like the API for host function environments needs to be changed so the function doesn't receive a mutable reference to its
Env
.The text was updated successfully, but these errors were encountered: