| 1ee10205 | 30-Mar-2026 |
Alex Crichton <[email protected]> |
Fix state of futures/streams after cancellation (#12881)
* Fix state of futures/streams after cancellation
This fixes two related but distinct issues with respect to delivering events to stream/fut
Fix state of futures/streams after cancellation (#12881)
* Fix state of futures/streams after cancellation
This fixes two related but distinct issues with respect to delivering events to stream/future handles. First when delivering an event to a future or a stream the shared code is now more unified into one path. This fixes an issue with futures where they would always have `done` flagged as `false` accidentally. This then fixes an additional issue where this `on_delivery` function wasn't invoked when futures/streams had their operations cancelled.
* Fix CI
show more ...
|
| 37c49428 | 30-Mar-2026 |
Alex Crichton <[email protected]> |
Fix a panic in `Bytes{,Mut}` `StreamProducer` impls (#12878)
This commit fixes the logic of these `impl`s to match the `Vec`-style blocks to relinquish the entire buffer to Wasmtime immediately. Thi
Fix a panic in `Bytes{,Mut}` `StreamProducer` impls (#12878)
This commit fixes the logic of these `impl`s to match the `Vec`-style blocks to relinquish the entire buffer to Wasmtime immediately. This fixes an issue where `split_off` is called with too large a value which can panic.
show more ...
|
| 8de60f18 | 02-Mar-2026 |
Jelle van den Hooff <[email protected]> |
Fix async stream cancel corrupting read/write state (#12704)
When `stream.cancel-read` or `stream.cancel-write` is called with the `async` option and the cancel cannot complete immediately (returns
Fix async stream cancel corrupting read/write state (#12704)
When `stream.cancel-read` or `stream.cancel-write` is called with the `async` option and the cancel cannot complete immediately (returns BLOCKED), the code was unconditionally transitioning the read/write state from GuestReady to Open. This destroyed the buffer address/count info stored in GuestReady, causing incorrect behavior when the host producer/consumer later tried to access the stream state.
Guard the GuestReady -> Open state transition with a check that the cancel did not return BLOCKED. When blocked, the cancel is still in-flight and the read/write state must be preserved until the cancel completes.
Adds a regression test that creates a host StreamProducer, starts an async read (BLOCKED), then async-cancels (BLOCKED), and waits for cancel completion.
show more ...
|
| 4137f4f3 | 19-Dec-2025 |
Joel Dice <[email protected]> |
relax intra-component stream/future read/write rules (#12181)
Per https://github.com/WebAssembly/component-model/pull/580, we now allow intra-component reads and writes for all numeric payloads.
Wh
relax intra-component stream/future read/write rules (#12181)
Per https://github.com/WebAssembly/component-model/pull/580, we now allow intra-component reads and writes for all numeric payloads.
While I was implementing this, Alex and I spotted a couple of bugs, which I've fixed here:
- We can't treat `bool` and `char` payloads as "flat" (i.e. trivially copy-able) since not all bit patterns are valid for those types. - We weren't enforcing the rules (old or new) for streams with non-"flat" payloads (i.e. the ones that most needed them enforced :facepalm:)
Also, now that https://github.com/WebAssembly/component-model/pull/578 has been merged, I've updated the `tests/component-model` submodule and reduced the list of "expect fail" tests for that directory.
Finally, note that the `p3_http_middleware_host_to_host` test is still expected to trap, but now for a different reason. Previously, it trapped because it tried to do an intra-component read/write on a `stream<u8>`. Now that that's allowed, it instead traps when doing an intra-component read/write on a `future<result<option<trailers>, error-code>>`, which is still prohibited.
Signed-off-by: Joel Dice <[email protected]>
show more ...
|
| f586be11 | 09-Dec-2025 |
Alex Crichton <[email protected]> |
cm-async: Start to fill out `{Future,Stream}Any` (#12142)
* cm-async: Start to fill out `{Future,Stream}Any`
This commit is the first step down the road of filling out the preexisting, but empty/bu
cm-async: Start to fill out `{Future,Stream}Any` (#12142)
* cm-async: Start to fill out `{Future,Stream}Any`
This commit is the first step down the road of filling out the preexisting, but empty/buggy, `FutureAny` and `StreamAny` types. These are intended to behave similarly to `ResourceAny` where the embedder doesn't have static knowledge ahead of time about the type of the future/stream in use. Changes made here are:
* `ComponentType for {Stream,Future}Reader<T>` now correctly typecheck the `T`. * Conversion to/from `*Any` types now properly typechecks the payload type against the expected type. * `{Future,Stream}Any` now live in their own file with the matrix of conversions to the typed variants. * A `close` method was added to `*Any` types.
These types are not currently directly constructible but this will likely be relaxed in the future. Additionally the host can't actually use these values without knowing the type, which is another restriction that will be relaxed in the future (aka implemented).
cc #11161
* Fix tests
* Skip a test on miri
show more ...
|
| 8992b99b | 09-Dec-2025 |
Joel Dice <[email protected]> |
trap on blocking call in sync task before return (#12043)
* trap on blocking call in sync task before return
This implements a spec change (PR pending) such that tasks created for calls to synchron
trap on blocking call in sync task before return (#12043)
* trap on blocking call in sync task before return
This implements a spec change (PR pending) such that tasks created for calls to synchronous exports may not call potentially-blocking imports or return `wait` or `poll` callback codes prior to returning a value. Specifically, the following are prohibited in that scenario:
- returning callback-code.{wait,poll} - sync calling an async import - sync calling subtask.cancel - sync calling {stream,future}.{read,write} - sync calling {stream,future}.cancel-{read,write} - calling waitable-set.{wait,poll} - calling thread.suspend
This breaks a number of tests, which will be addressed in follow-up commits:
- The `{tcp,udp}-socket.bind` implementation in `wasmtime-wasi` is implemented using `Linker::func_wrap_concurrent` and thus assumed to be async, whereas the WIT interface says they're sync, leading to a type mismatch error at runtime. Alex and I have discussed this and have a general plan to address it.
- A number of tests in the tests/component-model submodule that points to the spec repo are failing. Those will presumably be fixed as part of the upcoming spec PR (although some could be due to bugs in this implementation, in which case I'll fix them).
- A number of tests in tests/misc_testsuite are failing. I'll address those in a follow-up commit.
Signed-off-by: Joel Dice <[email protected]>
* call `check_may_leave` before `check_blocking`
`check_blocking` needs access to the current task, but that's not set for post-return functions since those should not be calling _any_ imports at all, so first check for that.
Signed-off-by: Joel Dice <[email protected]>
* fix `misc_testsuite` test regressions
This amounts to adding `async` to any exported component functions that might need to block.
Signed-off-by: Joel Dice <[email protected]>
* simplify code in `ConcurrentState::check_blocking`
Signed-off-by: Joel Dice <[email protected]>
* make `thread.yield` a no-op in non-blocking contexts
Per the proposed spec changes, `thread.yield` should return control to the guest immediately without allowing any other thread to run. Similarly, when an async-lifted export or callback returns `CALLBACK_CODE_YIELD`, we should call the callback again immediately without allowing another thread to run.
Signed-off-by: Joel Dice <[email protected]>
* fix build when `component-model-async` feature disabled
Signed-off-by: Joel Dice <[email protected]>
* fix more test regressions
Signed-off-by: Joel Dice <[email protected]>
* fix more test regressions
Note that this temporarily updates the `tests/component-model` submodule to the branch for https://github.com/WebAssembly/component-model/pull/577 until that PR is merged.
Signed-off-by: Joel Dice <[email protected]>
* tweak `Trap::CannotBlockSyncTask` message
This clarifies that such a task cannot block prior to returning.
Signed-off-by: Joel Dice <[email protected]>
* fix cancel_host_future test
Signed-off-by: Joel Dice <[email protected]>
* trap sync-lowered, guest->guest async calls in sync tasks
I somehow forgot to address this earlier. Thanks to Luke for catching this.
Note that this commit doesn't include test coverage, but Luke's forthecoming tests in the `component-model` repo will cover it, and we'll pull that in with the next submodule update.
Signed-off-by: Joel Dice <[email protected]>
* switch back to `main` branch of `component-model` repo
...and skip or `should_fail` the tests that won't pass until https://github.com/WebAssembly/component-model/pull/578 is merged.
Signed-off-by: Joel Dice <[email protected]>
* add `trap-if-block-and-sync.wast`
We'll remove this again in favor of the upstream version once https://github.com/WebAssembly/component-model/pull/578 has been merged.
Signed-off-by: Joel Dice <[email protected]>
* address review feedback
- Assert that `StoreOpaque::suspend` is not called in a non-blocking context except in specific circumstances
- Typecheck async-ness for dynamic host functions
- Use type parameter instead of value parameter in `call_host[_dynamic]`
Signed-off-by: Joel Dice <[email protected]>
* add explanation comments to `check_blocking` calls
Signed-off-by: Joel Dice <[email protected]>
* fix fuzz test oracle for async functions
Signed-off-by: Joel Dice <[email protected]>
---------
Signed-off-by: Joel Dice <[email protected]>
show more ...
|