Skip to content
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

Engine deadlocks when calling from host function to WASM. #567

Closed
Berrysoft opened this issue Nov 18, 2022 · 4 comments
Closed

Engine deadlocks when calling from host function to WASM. #567

Berrysoft opened this issue Nov 18, 2022 · 4 comments

Comments

@Berrysoft
Copy link
Contributor

The Engine locks when calling a WASM function. If the WASM function calls a host function, and the host function calls another WASM function, it deadlocks.

         lock                                deadlock
host ------------> WASM ------------> host ------------> WASM

Unfortunately, my use case heavily depends on this calling routine. The host function calls a WASM function to make an ABI-compatible allocation. The same code passes on Wasmtime. It seems not a simple problem to solve, but I think it is better to point it out.

@Robbepop
Copy link
Member

Robbepop commented Nov 18, 2022

I am aware of this problem. I was not aware that Wasmtime allows this behavior though. However, it is actually simpler with a JIT compiler compared to an interpreter since there is much more state in an interpreter that needs to be carried over to new function executions.
As you pointed out this won't be simple to implement on the wasmi side. Can you tell me more about your use case in particular? I thought it was not very important so far which is why we never focused on fixing this issue.

It is not impossible to fix. We could probably solve this by allowing multiple executors per engine and create new executors on the fly and reuse old ones to reduce frequent heap allocations. Currently we only have a single executor per engine.

@Berrysoft
Copy link
Contributor Author

Well, if it is difficult to solve, it's OK. I'll try to remove these allocations to make sure no deadlocks :)

@Robbepop
Copy link
Member

@Berrysoft btw thank you a lot for writing all those issues! That really help us improving wasmi. 😊

@Robbepop
Copy link
Member

Closed in favor of #572.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants