You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 and B, where B imports an exported interface from A, with a function add-callback(...) which is called from component B, and component B exports a function handle-callback(...) which will be call by component A . A doesn't know about the existence of B 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 a filter, so e.g. B calls filter in A with a function in B as the predicate, and then A calls the predicate immediately, because the stack trace would contain B->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:
Components prevent unexpected reentrance by setting the "lockdown" state (in the previous bullet) whenever calling out through an import, clearing the lockdown state on return, thereby preventing reentrant export calls in the interim. This establishes a clear contract between separate components that both prevents obscure composition-time bugs and also enables more-efficient non-reentrant runtime glue code (particularly in the middle of the Canonical ABI).
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: