Stream: wasmtime

Topic: Stack trace with details from a host function


view this post on Zulip Tomas Olvecky (Jan 13 2025 at 13:44):

I have enabled wasmtime::WasmBacktraceDetails and I can see the stack trace with files and line numbers, but only when the guest traps.
I did not succeed producing a detailed stack trace when the guest calls a host function. I tried returning an Err variant, but the caller (guest) file and line number is missing. The host function is defined using LinkerInstance.html#method.func_new_async.

Is it a bug, a limitation or is there another way to obtain the stack trace with line numbers from a host function?

view this post on Zulip Alex Crichton (Jan 13 2025 at 15:25):

I forget exactly where this happens but if you're not seeing a backtrace on Err then I suspect we only auto-capture backtraces on traps. You can use WasmBacktrace::capture though (or force_capture) to do the same programmatically though

view this post on Zulip Tomas Olvecky (Jan 13 2025 at 17:40):

Thanks @Alex Crichton , the WasmBacktrace was the right direction. I was looking at {err:?}, but one needs to use error.downcast_ref::<WasmBacktrace>().


Last updated: Jan 24 2025 at 00:11 UTC