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
I'm writing an error handler which converts wasm panics into wasmer RuntimeError using RuntimeError::raise. I do that by calling raise from a custom_exit import. This import is called in wasm using std::panic::set_hook. The panic callback convert the PanicInfo into a string, then calls custom_exit with the str pointer and len.
One trouble I have is about getting a handle to Memory from the callback rust-side. It needs a handle to the instance memory for new_native_with_env to create the imports, but this memory is only accessible after creating the instance. I ended up using a Rc<RefCell<Option<Memory>>> as env and init it after instance creation, but it looks horrible.
Proposed solution
There should be a way to access the instance memory from the instance. In a lot of case, native wasm types will not be enough and you will need read and write the Wasm memory. Not sure how that would work out, though... Maybe by passing as first argument?
Alternatives
Additional context
The text was updated successfully, but these errors were encountered:
We are actively discussing a number of proposals for API changes to make this ergonomic! I think this is the most important thing we need to address in the Wasmer API right now so I'm trying to prioritize it, but it's a potentially big change and something that will have implications for our API for a long time so I want to make sure we find a scalable solution that we're happy with.
I'll try to remember to post about it publicly when we have more news to share here!
Since Wasmer 2.0, there is no more panic. All “panics” are now translated to RuntimeError. I am likely to be wrong but I think it's been solved in #2305.
Motivation
I'm writing an error handler which converts wasm panics into wasmer RuntimeError using
RuntimeError::raise
. I do that by callingraise
from acustom_exit
import. This import is called in wasm usingstd::panic::set_hook
. The panic callback convert the PanicInfo into a string, then callscustom_exit
with the str pointer and len.One trouble I have is about getting a handle to
Memory
from the callback rust-side. It needs a handle to the instance memory fornew_native_with_env
to create the imports, but this memory is only accessible after creating the instance. I ended up using aRc<RefCell<Option<Memory>>>
as env and init it after instance creation, but it looks horrible.Proposed solution
There should be a way to access the instance memory from the instance. In a lot of case, native wasm types will not be enough and you will need read and write the Wasm memory. Not sure how that would work out, though... Maybe by passing as first argument?
Alternatives
Additional context
The text was updated successfully, but these errors were encountered: