bytecodealliance / bytecodealliance/wasmtime

Ensure fibers are always disposed of gracefully in `wasmtime::runtime::component::concurrent`

Open
#14,241 0 comments 0 reactions 0 assignees View on GitHub
wasm-proposal:component-model-async
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.