-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allowing reentrance of wasm components #9600
Comments
cc WebAssembly/component-model#234 Reentrance is not allowed by Wasmtime because the spec says so. As for why this is the case, see https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md:
|
any progress? |
@Nimaoth @BERADQ here @bjorn3 is correct in that Wasmtime's current behavior is an implementation of the current component model specification. For changing the behavior here I think it would be best to raise this issue on the component-model repository itself to gather interest among stakeholders there. Wasmtime is unlikely to change behavior in this regard unless there's interest in the specification itself for changing, so inevitably the first step will be to kick off the discussion there. |
Hi, I'm currently experimenting with wasm components for a plugin system, and one use case I have is being able to do callbacks between components.
So say we have two components
A
andB
, whereB
imports an exported interface fromA
, with a functionadd-callback(...)
which is called from componentB
, and componentB
exports a functionhandle-callback(...)
which will be call by componentA
.A
doesn't know about the existence ofB
at compile time (they are dynamically linked).It would work fine for callbacks which are call later (e.g. by an event in the host).
The problem now is that since reentrant calls aren't allowed, I can't do this for callbacks which are called immediately (like a
predicate
function for afilter
, so e.g.B
callsfilter
inA
with a function inB
as the predicate, and thenA
calls the predicate immediately, because the stack trace would containB
->A
->B
and would reenter B).So I just tried disabling the reentrance checks in
runtime/component/func.rs
and it seems to work fine for my tests. The question here is are there any technical reasons for why the reentrance is dissallowed (e.g. memory saftety violation, deadlocks, race conditions), or is it only because the component model defines this?If there is no hard requirement for it would it then be possible add a feature to allow reentrance for certain components?
The text was updated successfully, but these errors were encountered: