Stream: wasmtime

Topic: ✔ getting panic message from guest


view this post on Zulip Lloyd Fournier (Apr 17 2023 at 05:44):

I want to get the panic message from a guest in for example a call to panic!("I failed because X").
From this issue: https://github.com/bytecodealliance/wasmtime/issues/4054 it sounds like this might not be possible but I wanted to check whether there's been any developments here. Thanks!

Feature I would like to have the ability to somehow get a panic reason in the result of invoking WebAssembly function. Currently, it returns wasm trap: wasm unreachable instruction execute. Benefit...

view this post on Zulip Lloyd Fournier (Apr 17 2023 at 05:54):

I forgot to mention that this is in the context of using wit-bindgen to generate the guest and compiling for wasm32-unknown-unknown.

view this post on Zulip bjorn3 (Apr 17 2023 at 09:55):

Webassembly doesn't provide a mechanism for the guest to provide the panic message. You can set a custom panic hook in the guest using std::panic::set_hook and then inside this panic hook call a host function to provide the panic message though.

view this post on Zulip bjorn3 (Apr 17 2023 at 09:57):

By the way be aware that wasm32-unknown-unknown doesn't use the correct C abi that wasm32-wasi and wasm32-unknown-emscripten use. A mistake was made when initially adding webassembly support to rustc and we can't change it anymore was wasm-bindgen depends on the broken abi. I'm not sure if wit-bindgen works correctly with the broken abi.

view this post on Zulip Lloyd Fournier (Apr 19 2023 at 13:14):

Thanks this set_hook worked for me. So far wit-bindgen is working great. Would be interested to know about this problem if you have any links?

view this post on Zulip Notification Bot (Apr 19 2023 at 13:14):

Lloyd Fournier has marked this topic as resolved.


Last updated: Nov 22 2024 at 16:03 UTC