bytecodealliance / bytecodealliance/wasmtime
Is if safe to have `unsafe impl Send + Sync` for custom types when using wasmtime in single thread?
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 135
Description
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.
Contributor guide
Research direction
Start with the linked Func documentation, especially the explanation of the Send, Sync, and 'static requirements. Determine whether unsafe impl Send + Sync is sound for custom types in a single-threaded Wasmtime use case, and document whether that guarantee is expected to change in future versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100