Disallow post-return from calling imports, allow blocking import calls even when callback is used#531
Merged
Merged
Conversation
alexcrichton
approved these changes
Jun 17, 2025
Collaborator
|
@lukewagner when you get a chance, would you mind adding a WAT test for this? That will help ensure implementations get it right. |
Member
Author
|
You bet; good idea: #535 |
dicej
added a commit
to dicej/wasmtime
that referenced
this pull request
Jun 27, 2025
Per WebAssembly/component-model#531, post-return functions are no longer allowed to call imports or intrinsics. TODO: Update FACT to trap with a "cannot leave component instance" message instead of the generic "wasm `unreachable` instruction executed". Signed-off-by: Joel Dice <joel.dice@fermyon.com>
dicej
added a commit
to dicej/wasmtime
that referenced
this pull request
Jun 27, 2025
Per WebAssembly/component-model#531, post-return functions are no longer allowed to call imports or intrinsics. TODO: Update FACT to trap with a "cannot leave component instance" message instead of the generic "wasm `unreachable` instruction executed". Signed-off-by: Joel Dice <joel.dice@fermyon.com>
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
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 PR disallows calling imports during
post-returnwhich means that sync-to-sync calls never require a fiber (noting that, ifpost-returncan call imports, it can block after returning-to-and-unblocking the synchronous caller, thereby requiring a fiber to continue asynchronous execution in the callee), preserving the intended cost model of synchronous calls.This implies that
post-returnwill stick around instead of getting deprecated and removed in the future, thereby removing the reason for having the (as yet unimplemented)always-task-returncanonopt. Note that, with only a bit more work, a synchronous export that wants to usetask.returncould always liftasync(nocallback) and usebackpressure.setto achieve serialized execution.The PR also relaxes a few of the traps that prevent certain blocking calls from being used in conjunction with
callback. These traps were intended to avoid the need for fibers in some cases, but based on implementation experience, we think they'll be too strict and prevent various realistic scenarios where an unaware transitive dependency does a little unexpected blocking. Notes and TODOs are added to Async.md explaining this more.