Closed
Description
As proposed in #708 the Store
type in the wasmtime API should be thread-safe, meaning it should implement both Send
and Sync
. Currently, however, it has a few items that are not thread safe and/or need audits:
Theglobal_exports
field is anRc
-protected data structure used by wasmtime internals. I don't know myself what it would take to remove this, but @sunfishcode looks like he does in Replace global-exports mechanism with caller-vmctx mechanism #390- The
signature_cache
field requires interior mutability and currently uses aRefCell
. While this could be switched to aMutex
I think it would be best to avoid this altogether. I don't personally know why this field exists, @yurydelendik do you know why it's here? - The
context
field has a containedcompiler
field which has a number of issues. NamelyRc
andRefCell
are not thread safe (but can be swapped forArc
/Mutex
if necessary), but the underlyingCompiler
type has a number of trait objects, raw pointers, etc, which would need auditing. I think the solution here is going to be makingCompiler
itself threadsafe by redesigning it's internals.