bytecodealliance / bytecodealliance/wasmtime
Ensure fibers are always disposed of gracefully in `wasmtime::runtime::component::concurrent`
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 121
Description
This module is responsible for wrangling fibers in various contexts (i.e. suspending, resuming, attaching them to waitable sets, etc.). That gets tricky when we need to move a fiber from one store-based owner to another, during which assertion failures, traps, or `bail_bugs` could happen such that the fiber is dropped before it has been put back into the store. That's a hazard because dropping a fiber which hasn't been allowed to exit (which requires exclusive access to a store) will itself panic, which can escalate e.g. a trap to a full blown crash.
As long as every fiber is owned by the store somehow, we're safe, because when the store is dropped, all its fibers are disposed of gracefully (assuming we've remembered to check all the places in the store where fibers can be kept). Likewise, we can wrap a fiber in an RAII object in combination with a store to ensure it is disposed of properly when the RAII object is dropped. Any time a fiber is not protected in one of those two ways, though, it's a hazard, so we should audit the code for such cases and fix them.
Contributor guide
Assessment
This issue has not been assessed yet.