|
Revision tags: dev, v36.0.9, v44.0.1, v43.0.2, v36.0.8, v24.0.8, v44.0.0, v43.0.1, v42.0.2, v36.0.7, v24.0.7, v43.0.0 |
|
| #
da093747 |
| 02-Mar-2026 |
Alex Crichton <[email protected]> |
Relax panics in async/futures to traps/errors (#12688)
* Relax panics in async/futures to traps/errors
This commit is an admittance that I don't believe we're going to get to a point where we are c
Relax panics in async/futures to traps/errors (#12688)
* Relax panics in async/futures to traps/errors
This commit is an admittance that I don't believe we're going to get to a point where we are confident enough in the fuzzing of component-model-async such that we could confidently say we're exercising the vast majority of possible panics. Development of component-model-async has shown a steady trickle of panics over the course of the development of the feature, and this trend has been persistent over time as well.
An attempt was made in #12119 to add a fuzzer dedicated to async events but that didn't actually find anything in development and it has missed a number of panics present before and discovered after its introduction. Overall I do not know how to improve the fuzzer to the point that it would find pretty much all of the existing async-related panics over time.
To help address this concern of the `concurrent.rs` implementation this commit goes through and replaces things like `unwrap()`, `assert!`, `panic!`, and `unreachable!` with an error-producing form. The benefit of this is that a bug in the implementation is less likely to result in a panic and instead just results in a non-spec-compliant trap. The downside of doing this though is that it can become unclear what errors are "first class traps", or expected to be guest reachable, and which are expected to be bugs in Wasmtime. To help address this I've performed a few refactorings here as well.
* Some traps previously present as error strings are now promoted to using `Trap::Foo` instead. This has some refactoring of the Rust/C side as well to make it easier to define new variants. Tests were additionally added for any trap messages that weren't previously tested as being reachable.
* A new `bail_bug!` macro was added (internally) for Wasmtime. This is coupled with a concrete `WasmtimeBug` error type (exported as `wasmtime::WasmtimeBug`). The intention is that `bail!` continues to be "here's a string and I'm a bit too lazy to make a concrete error" while `bail_bug!` indicates "this is a bug in wasmtime please report this if you see it".
The rough vision is that if an error condition is reached, and the system is not broken in such a way that panicking is required, then `bail_bug!` can be used to indicate a bug in Wasmtime as opposed to panicking. This reduces the real-world impact of hitting these scenarios by downgrading a CVE-worthy `panic!` into a bug-worthy non-spec-compliant trap. Not all panics are able to be transitioned to this as some are load bearing from a safety perspective or similar (or indicate something equally broken), but the vast majority of cases are suitable for "return a trap, lock down the store, and let destructors take care of everything else".
This change additionally has resulted in API changes for `FutureReader` and `StreamReader`. For example creation of these types now returns a `Result` for when the `ResourceTable` is full, for example, instead of panicking.
* Fix CI build
* Translate `WasmtimeBug` to panics in debug mode
* Review comments
* Refactor some stream methods for fewer panics
show more ...
|
|
Revision tags: v42.0.1, v41.0.4, v42.0.0, v40.0.4, v36.0.6, v24.0.6, v41.0.3, v41.0.2, v41.0.1, v36.0.5, v40.0.3 |
|
| #
e472f50c |
| 23-Jan-2026 |
Alex Crichton <[email protected]> |
Fix component-async fuzzer on OSS-Fuzz (#12400)
On OSS-Fuzz the fuzzers are built in one place and run in another, so `include_bytes!` is needed to get the wasm into the final binary. This is done w
Fix component-async fuzzer on OSS-Fuzz (#12400)
On OSS-Fuzz the fuzzers are built in one place and run in another, so `include_bytes!` is needed to get the wasm into the final binary. This is done with a layer of macros to avoid an `include_bytes!` for all wasm programs which would make the generated Rust metadata a bit... large.
show more ...
|
| #
cc8d04f4 |
| 23-Jan-2026 |
Alex Crichton <[email protected]> |
Remove need for explicit `Config::async_support` knob (#12371)
* Refactor component model host function definitions
Push the `async`-ness down one layer.
* Remove need for explicit `Config::async
Remove need for explicit `Config::async_support` knob (#12371)
* Refactor component model host function definitions
Push the `async`-ness down one layer.
* Remove need for explicit `Config::async_support` knob
This commit is an attempt to step towards reconciling "old async" and "new async" in Wasmtime. The old async style is the original async support in Wasmtime with `call_async`, `func_wrap_async`, etc, where the main property is that the store is "locked" during an async operation. Put another way, a store can only execute at most one async operation at a time. This is in contrast to "new async" support in Wasmtime with the component-model-async (WASIp3) support, where stores can have more than one async operation in flight at once.
This commit does not fully reconcile these differences, but it does remove one hurdle along the way: `Config::async_support`. Since the beginning of Wasmtime this configuration knob has existed to explicitly demarcate a config/engine/store as "this thing requires `async` stuff internally." This has started to make less and less sense over time where the line between sync and async has become more murky with WASIp3 where the two worlds comingle. The goal of this commit is to deprecate `Config::async_support` and make the function not actually do anything.
In isolation this can't simply be done, however, because there are many load-bearing aspects of Wasmtime that rely on this `async_support` knob. For example once epochs + yielding are enabled it's required that all Wasm is executed on a fiber lest it hit an epoch and not know how to yield. That means that this commit is not a simple removal of `async_support` but instead a refactoring/rearchitecting of how async is used internally within Wasmtime. The high-level ideas within Wasmtime now are:
* A `Store` has a "requires async" boolean stored within it. * All configuration options which end up requiring async, such as yielding with epochs, turn this boolean on. * Creation of host functions which use async (e.g. `func_wrap_{async,concurrent}`) will also turn this option on. * Synchronous API entrypoints into Wasmtime ensure that this boolean is disabled. * Asynchronous APIs are usable at any time.
This means that the concept of an async store vs a sync store is now gone. All stores are equally capable of executing sync/async, and the change now is that dynamically some stores will require that async is used with certain configuration. Additionally all panicking conditions around `async_support` have been converted to errors instead. All relevant APIs already returned an error and things are murky enough now that it's not necessarily trivial to get this right at the embedder level. In the interest of avoiding panics all detected async mismatches are now first-class `wasmtime::Error` values.
The end result of this commit is that `Config::async_support` is a deprecated `#[doc(hidden)]` function that does nothing. While many internal changes happened as well as having new tests for all this sort of behavior this is not expected to have a great impact on external consumers. In general a deletion of `async_support(true)` is in theory all that's required. This is intended to make it easier to think about async/sync/etc in the future with WASIp3 and eventually reconcile `func_wrap_async` and `func_wrap_concurrent` for example. That's left for future refactorings however.
prtest:full
* Review comments
* Fix CI failures
show more ...
|
|
Revision tags: v41.0.0, v36.0.4, v39.0.2, v40.0.2, v40.0.1, v40.0.0 |
|
| #
fee9be21 |
| 09-Dec-2025 |
Alex Crichton <[email protected]> |
Add a new fuzzer focused on component-model-async events (#12119)
* Add a new fuzzer focused on component-model-async events
This commit adds a new fuzzer mode to the `misc` fuzzer of Wasmtime whic
Add a new fuzzer focused on component-model-async events (#12119)
* Add a new fuzzer focused on component-model-async events
This commit adds a new fuzzer mode to the `misc` fuzzer of Wasmtime which is focused on async events and interleavings of components using the component-model-async proposal. This fuzzer works by having a precompiled guest program which serves as the component to run. This precompiled component has a custom `fuzz.wit` which is used to interface with the fuzzer itself. The fuzzer is then a fuzz-generated sequence of commands to send to the component which verifies that everything executes correctly, has no panics, etc.
This fuzzer intends to stress async communication and task infrastructure with component-model-async. Notably this does not stress lifting/lowering or arbitrary type signatures. This does, however, permute all of the following:
* Guest/host interactions (also guest/guest, host/host, etc). * Async functions, both ready and pending. * Future operations: reads, writes, cancellation, transfers, etc. * Stream operations: reads, writes, cancellation, transfers, etc.
This is all throwing into a large "soup" and then asserted to work correctly. There's a few gotchas here and there for how this fuzzer is designed, such as some events requiring "yield N times to await this event happening". This is required because Wasmtime is allowed to non-deterministically select between a number of "ready events" and what to dispatch.
This is not intended to be a one-size-fits-all fuzzer for component-model-async. The recent enhancements to the `component_api` fuzzer are intended to complement this fuzzer in terms of what's stressed where internally.
* Review comments
show more ...
|