Stream: git-wasmtime

Topic: wasmtime / issue #5936 Is if safe to have `unsafe impl Se...


view this post on Zulip Wasmtime GitHub notifications bot (Mar 06 2023 at 14:55):

ValeryAntopol opened issue #5936:

I read the docs about the Send + Sync + 'static requirement https://docs.rs/wasmtime/latest/wasmtime/struct.Func.html#why-send--sync--static, and it suggests passing most of the data through the store. However, it is not easy to do it in my case and forces me to change many Rc -> Arc and even add a mutex, without any other reasons except wasmtime's requirements. So it is a

I understand that it is generally unsafe to have unsafe impl, but if wasmtime uses thread-safety guarantees only to make its structures thread-safe and does not rely on them internally, it will be fine. The question refers to the latest version at the time of aswering, and if answer is "safe" then it would be nice to know if it is expected to change in future.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 06 2023 at 15:33):

alexcrichton commented on issue #5936:

This is technically allows because Wasmtime doesn't spawn any threads for you (except when compiling modules with parallel-compilation enabled which isn't related to the runtime).

If you can get it to work, however, the intention is that non-Send-and-Sync state would be stored in the T of the Store<T> which all functions get access to. That way your host functions which are Send + Sync + 'static typically don't actually close over anything and they're just function pointers.


Last updated: Oct 23 2024 at 20:03 UTC