-
Notifications
You must be signed in to change notification settings - Fork 99
add async to funcs that need to block in WAST tests
#577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This anticipates the forthcoming changes to WIT/CM async and helps us get CI green for bytecodealliance/wasmtime#12043 Signed-off-by: Joel Dice <joel.dice@fermyon.com>
dicej
added a commit
to dicej/wasmtime
that referenced
this pull request
Nov 25, 2025
Note that this temporarily updates the `tests/component-model` submodule to the branch for WebAssembly/component-model#577 until that PR is merged. Signed-off-by: Joel Dice <joel.dice@fermyon.com>
dicej
added a commit
to dicej/wasmtime
that referenced
this pull request
Dec 1, 2025
Note that this temporarily updates the `tests/component-model` submodule to the branch for WebAssembly/component-model#577 until that PR is merged. Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Member
|
These test fixes are now folded into #578, so I think we can close this. |
github-merge-queue bot
pushed a commit
to bytecodealliance/wasmtime
that referenced
this pull request
Dec 9, 2025
* 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 <joel.dice@fermyon.com>
* 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 <joel.dice@fermyon.com>
* 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 <joel.dice@fermyon.com>
* simplify code in `ConcurrentState::check_blocking`
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* 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 <joel.dice@fermyon.com>
* fix build when `component-model-async` feature disabled
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* fix more test regressions
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* fix more test regressions
Note that this temporarily updates the `tests/component-model` submodule to the
branch for WebAssembly/component-model#577 until that PR
is merged.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* tweak `Trap::CannotBlockSyncTask` message
This clarifies that such a task cannot block prior to returning.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* fix cancel_host_future test
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* 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 <joel.dice@fermyon.com>
* switch back to `main` branch of `component-model` repo
...and skip or `should_fail` the tests that won't pass until
WebAssembly/component-model#578 is merged.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* add `trap-if-block-and-sync.wast`
We'll remove this again in favor of the upstream version once
WebAssembly/component-model#578 has been merged.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* 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 <joel.dice@fermyon.com>
* add explanation comments to `check_blocking` calls
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
github-merge-queue bot
pushed a commit
to bytecodealliance/wasmtime
that referenced
this pull request
Dec 9, 2025
* 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 <joel.dice@fermyon.com>
* 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 <joel.dice@fermyon.com>
* 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 <joel.dice@fermyon.com>
* simplify code in `ConcurrentState::check_blocking`
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* 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 <joel.dice@fermyon.com>
* fix build when `component-model-async` feature disabled
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* fix more test regressions
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* fix more test regressions
Note that this temporarily updates the `tests/component-model` submodule to the
branch for WebAssembly/component-model#577 until that PR
is merged.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* tweak `Trap::CannotBlockSyncTask` message
This clarifies that such a task cannot block prior to returning.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* fix cancel_host_future test
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* 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 <joel.dice@fermyon.com>
* switch back to `main` branch of `component-model` repo
...and skip or `should_fail` the tests that won't pass until
WebAssembly/component-model#578 is merged.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* add `trap-if-block-and-sync.wast`
We'll remove this again in favor of the upstream version once
WebAssembly/component-model#578 has been merged.
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* 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 <joel.dice@fermyon.com>
* add explanation comments to `check_blocking` calls
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* fix fuzz test oracle for async functions
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
---------
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
alexcrichton
pushed a commit
to alexcrichton/wasmtime
that referenced
this pull request
Dec 9, 2025
) * 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 <joel.dice@fermyon.com> * 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 <joel.dice@fermyon.com> * 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 <joel.dice@fermyon.com> * simplify code in `ConcurrentState::check_blocking` Signed-off-by: Joel Dice <joel.dice@fermyon.com> * 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 <joel.dice@fermyon.com> * fix build when `component-model-async` feature disabled Signed-off-by: Joel Dice <joel.dice@fermyon.com> * fix more test regressions Signed-off-by: Joel Dice <joel.dice@fermyon.com> * fix more test regressions Note that this temporarily updates the `tests/component-model` submodule to the branch for WebAssembly/component-model#577 until that PR is merged. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * tweak `Trap::CannotBlockSyncTask` message This clarifies that such a task cannot block prior to returning. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * fix cancel_host_future test Signed-off-by: Joel Dice <joel.dice@fermyon.com> * 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 <joel.dice@fermyon.com> * switch back to `main` branch of `component-model` repo ...and skip or `should_fail` the tests that won't pass until WebAssembly/component-model#578 is merged. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * add `trap-if-block-and-sync.wast` We'll remove this again in favor of the upstream version once WebAssembly/component-model#578 has been merged. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * 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 <joel.dice@fermyon.com> * add explanation comments to `check_blocking` calls Signed-off-by: Joel Dice <joel.dice@fermyon.com> * fix fuzz test oracle for async functions Signed-off-by: Joel Dice <joel.dice@fermyon.com> --------- Signed-off-by: Joel Dice <joel.dice@fermyon.com>
alexcrichton
added a commit
to bytecodealliance/wasmtime
that referenced
this pull request
Dec 10, 2025
* 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 <joel.dice@fermyon.com> * 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 <joel.dice@fermyon.com> * 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 <joel.dice@fermyon.com> * simplify code in `ConcurrentState::check_blocking` Signed-off-by: Joel Dice <joel.dice@fermyon.com> * 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 <joel.dice@fermyon.com> * fix build when `component-model-async` feature disabled Signed-off-by: Joel Dice <joel.dice@fermyon.com> * fix more test regressions Signed-off-by: Joel Dice <joel.dice@fermyon.com> * fix more test regressions Note that this temporarily updates the `tests/component-model` submodule to the branch for WebAssembly/component-model#577 until that PR is merged. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * tweak `Trap::CannotBlockSyncTask` message This clarifies that such a task cannot block prior to returning. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * fix cancel_host_future test Signed-off-by: Joel Dice <joel.dice@fermyon.com> * 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 <joel.dice@fermyon.com> * switch back to `main` branch of `component-model` repo ...and skip or `should_fail` the tests that won't pass until WebAssembly/component-model#578 is merged. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * add `trap-if-block-and-sync.wast` We'll remove this again in favor of the upstream version once WebAssembly/component-model#578 has been merged. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * 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 <joel.dice@fermyon.com> * add explanation comments to `check_blocking` calls Signed-off-by: Joel Dice <joel.dice@fermyon.com> * fix fuzz test oracle for async functions Signed-off-by: Joel Dice <joel.dice@fermyon.com> --------- Signed-off-by: Joel Dice <joel.dice@fermyon.com> * Update release notes --------- Signed-off-by: Joel Dice <joel.dice@fermyon.com> Co-authored-by: Joel Dice <joel.dice@fermyon.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This anticipates the forthcoming changes to WIT/CM async and helps us get CI green for bytecodealliance/wasmtime#12043