-
Notifications
You must be signed in to change notification settings - Fork 258
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
stack trace API #159
Comments
This sounds useful. We are working on support for stack traces to Lucet right now. I'm not super familiar with that functionality in emscripten, can you provide a link to the implementation? |
WebAssembly/debugging#5 overlaps with this. |
Emscripten's implementation can be found at https://github.com/emscripten-core/emscripten/blob/7e93e0398b0c761d5f16ee507ad13016a9503443/src/library.js#L4275-L4487 |
LLVM also knows how to automatically convert |
This sounds useful to me too. A few questions that occur to me at first glance: Is the stack trace expected to be deterministic, in the presence of inlining or other optimizations? Should we expect all wasm engines to implement it? Or perhaps all engines which implement wasm EH? We can definitely put it in its own module and make it feature-testable with optional imports, but the question will come in LLVM -- should LLVM import the module unconditionally, or dynamically test for it? Would it makes sense to make |
JS is working on a way to hide functions from stack traces for security reasons. Would we want to consider similar functionality? |
Erlang and Elixir are used to stack traces being “incomplete” because all tail calls under go tail call optimizations, so we don’t have any objection to hiding calls for security or other reasons. I’d prefer it over and JDK situation where stack traces were spec’d as having to have all calls, which made Clojure and JRuby messier. |
Do you mean inlining and optimizations performed by the engine? I don't have much of an opinion on that because I'm not super familiar with the relevant tradeoffs. I would not expect the stack trace to be preserved across optimizations performed by toolchains, though, so this is a question for engine implementors rather than language implementors.
I think this would be reasonable. I assume all production engines today have some way of reporting the location of a trap, and this would be similar.
Yes, that sounds fine to me. |
Discussing with @sunfishcode, we're thinking this is more of a core VM feature than a WASI issue. It also seems like work in the core CG (e.g. around unwinding and stack switching) is reasonably likely to lead to a stack trace debugging mechanism, so I'm going to close this one for now. |
In the last meeting, there was some support for this so let's put it up for a vote. A couple of people (Luke, Syrus) suggested this could or should be a core level proposal; I agree this _could_ be a good place, but WASI's recent change to become a collection of "standard interfaces" instead of "system interfaces" suggests WASI as a suitable place as well. Additionally, moving this to phase 1 makes it possible to prototype with this API under a flag and sort out the details before we need to decide exactly where this needs to live. As support improves for languages that reflect stack traces in errors, we should soon here whether what was presented here is enough. Note that @tlively floated a similar idea to this almost exactly four years ago in [WASI#159]. [WASI#159]: WebAssembly/WASI#159
In the last meeting, I heard some support for this idea so let's put it up for a vote. A couple of people (Luke, Syrus) suggested that wasi-backtrace could or should be a core level proposal; I agree that the core spec _could_ be a good place, but WASI's recent change to become a collection of "standard interfaces" instead of "system interfaces" suggests WASI as a suitable place as well. Additionally, moving this to phase 1 makes it possible to prototype with this API under a flag and sort out the details before we need to decide exactly where this needs to live. As support improves for languages that reflect stack traces in errors, we should soon hear whether what was presented here is a good fit. Note that @tlively floated a similar idea to this almost exactly four years ago in [WASI#159]. [WASI#159]: WebAssembly/WASI#159
In the last meeting, I heard some support for this idea so let's put it up for a vote. A couple of people (Luke, Syrus) suggested that wasi-backtrace could or should be a core level proposal; I agree that the core spec _could_ be a good place, but WASI's recent change to become a collection of "standard interfaces" instead of "system interfaces" suggests WASI as a suitable place as well. Additionally, moving this to phase 1 makes it possible to prototype with this API under a flag and sort out the details before we need to decide exactly where this needs to live. As support improves for languages that reflect stack traces in errors, we should soon hear whether what was presented here is a good fit. Note that @tlively floated a similar idea to this almost exactly four years ago in [WASI#159]. [WASI#159]: WebAssembly/WASI#159
Many applications need stack traces for proper logging and debugging support, but due to WebAssembly's Harvard architecture and structured control flow, it is impossible to implement stack traces in WebAssembly without help from the embedder.
Emscripten has a bespoke stack trace API that parses and caches JS stack traces, but that is not usable outside a JS embedding, so it would make sense to standardize a WASI API for stack traces that all embedders can implement. Stack traces give WebAssembly modules introspection capabilities they would not otherwise have, so the API should require a capability.
The text was updated successfully, but these errors were encountered: