dicej requested alexcrichton for a review on PR #12349.
dicej requested wasmtime-compiler-reviewers for a review on PR #12349.
dicej opened PR #12349 from dicej:reentrance-refactor-part1 to bytecodealliance:main:
This commit makes a few changes related to recursive reentrance checks, instance poisoning, etc.:
- Implements the more restrictive lift/lower rules described in https://github.com/WebAssembly/component-model/pull/589 such that a component instance may not lower a function lifted by one of its ancestors, nor vice-versa. Any such lower will result in a fused adapter which traps unconditionally, preventing guest-to-guest recursive reentrance without requiring data flow analysis.
- Note that this required updating several WAST tests which were violating the new rule, including some in thetests/component-modelGit submodule, which I've updated.
- This is handled entirely in thefactmodule now; I've removed theAlwaysTrapcase previously handled bywasmtime-cranelift.- Removes
FLAG_MAY_ENTERfromInstanceFlags. It is no longer needed for guest-to-guest calls due to the above, and for guest-to-host-to-guest calls we can rely on eitherFLAG_NEEDS_POST_RETURNfor sync-lifted functions or theGuestTaskcall stack for async-lifted functions.- Adds a
StoreOpaque::trappedfield which is set when _any_ instance belonging to that store traps, at which point the entire store is considered poisoned, meaning no instance belonging to it may be entered. This prevents indeterminant concurrent task state left over from the trapping instance from leaking into other instances.Note that this does _not_ include code to push and pop
GuestTaskinstances for guest-to-guest sync-to-sync calls, nor for host-to-guest calls using e.g. the synchronousFunc::callAPI, so certain intrinsics which expect aGuestTaskto be present such asbackpressure.incwill still fail in such cases. I'll address that in a later PR.Also note that I made a small change to
wasmtime-wit-bindgen, adding aSendbound on theTtype parameter forstore | asyncfunctions. This allowed me to recursively call{Typed}Func::call_concurrentfrom inside a host function, and it doesn't have any downsides AFAICT.Fixes #12128
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
dicej requested wasmtime-core-reviewers for a review on PR #12349.
dicej updated PR #12349.
alexcrichton submitted PR review:
Minor comments here and there, but overall looks great, thanks!
alexcrichton created PR review comment:
stray refactoring leftover?
alexcrichton created PR review comment:
To confirm, this is a debugging/testing artifact and not a required part of this change?
alexcrichton created PR review comment:
You can avoid
StoreComponentInstanceId::new(...).get(...)here by callingself.component_instance(instance.instance)directly I think
alexcrichton created PR review comment:
I'm surprised that existing trait implementations don't need to update with this, but I suspect that's because if the trait requires more things and then your impl requires less it's sort of a subtype relation and allowed.
alexcrichton created PR review comment:
Given the destructor-ish nature of
previous_runtime_stateand the mild confusion with a closure, could this be inverted as, aftercatch_traps, anif result.is_err() { store.0.set_trapped(); }?
alexcrichton created PR review comment:
To avoid
#[cfg]here, how about putting this inComponentStoreDataand defining the methods in that file as well? Also helps to clarify that this is purely scoped to components, not applicable to core wasm.
dicej submitted PR review.
dicej created PR review comment:
It allows me to propagate the trap in the
async_round_trip_synchronous_recursetests. I.e. it's a change needed by a tests added to cover certain host-to-guest-to-host scenarios addressed by this PR.
dicej updated PR #12349.
dicej created PR review comment:
Yes, that's my understanding.
dicej submitted PR review.
dicej submitted PR review.
dicej created PR review comment:
This is a result of moving
RuntimeInstanceto a different module.
dicej edited PR review comment.
dicej updated PR #12349.
dicej has enabled auto merge for PR #12349.
dicej updated PR #12349.
dicej added PR #12349 refactor recursive reentrance checks to the merge queue.
github-merge-queue[bot] removed PR #12349 refactor recursive reentrance checks from the merge queue.
dicej updated PR #12349.
dicej has enabled auto merge for PR #12349.
dicej updated PR #12349.
dicej added PR #12349 refactor recursive reentrance checks to the merge queue.
dicej merged PR #12349.
dicej removed PR #12349 refactor recursive reentrance checks from the merge queue.
Last updated: Jan 29 2026 at 13:25 UTC