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

support abort the VM execution from imported function call. #58

Closed
laizy opened this issue Jul 24, 2019 · 8 comments
Closed

support abort the VM execution from imported function call. #58

laizy opened this issue Jul 24, 2019 · 8 comments
Assignees
Labels
🎉 enhancement New feature or request

Comments

@laizy
Copy link

laizy commented Jul 24, 2019

Motivation

In our use case, we need do some check in the imported go function, if check failed, it means a fatal error, and we need abort the whole VM execution, so add a InstanceContext.Trap(err) like method for imported function to call will be helpful.

@laizy laizy added the 🎉 enhancement New feature or request label Jul 24, 2019
@laizy
Copy link
Author

laizy commented Jul 25, 2019

seems this feature is supported in this wasmer pr167.

@Hywan Hywan self-assigned this Aug 28, 2019
@Hywan
Copy link
Contributor

Hywan commented Aug 28, 2019

Thanks for the suggestion. This is an interesting feature to implement. That's not an easy one though, because Go uses the C API of Wasmer. Let's see how far we can go!

@Hywan
Copy link
Contributor

Hywan commented Nov 18, 2019

Just a heads up to say I'm not forgetting this. The trapping system for host functions (aka imported functions) are implemented in Rust. For the C API, and therefore for Go, there is nothing, and I'm thinking of a new API for that. It'll take some time though.

@AdamSLevy
Copy link
Contributor

AdamSLevy commented Dec 11, 2019

I would really like to see this as I am trying to recover from panics in my host functions and this is sometimes causing stack smashing, which is unrecoverable. This problem seems somewhat unpredictable, so a safe way to TRAP from within a host function is critical to my application. I really like the panic()/recover() paradigm for this. @Hywan, can you point me at the API in Rust for this, and also any work on the Rust/C API so far? I would like to use this in my application ahead of it getting merged here. I will open PRs for any progress that I make on it.

@Hywan
Copy link
Contributor

Hywan commented Dec 12, 2019

Yeah, I'm thinking about it but it's not that obvious. I can focus on it next days.

@rusenask
Copy link

Thanks @Hywan for linking to this, from the issue's title it didn't seem connected but yeah, seems like the same problem.

In my case it's the same, need to trap them and can probably go some lengths getting this done as it's the last part before I can try my experiment in the real world :)

Ideally wasmer would return an error, less ideal scenario would be to put recover() in the function that is calling it.

@Hywan
Copy link
Contributor

Hywan commented Jan 6, 2020

Yeah, we should break our C API, and I'm not sure whether it's a good idea or not. I'm thinking about introducing a new C API for such cases instead.

@jubianchi
Copy link
Contributor

This feature is now implemented in wasmer-go. You can have a look at examples/example_early_exit_test.go to see how you can trigger traps from host functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants