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

Add origin information about Wasm traps #28

Closed
tailhook opened this issue Jan 29, 2018 · 6 comments
Closed

Add origin information about Wasm traps #28

tailhook opened this issue Jan 29, 2018 · 6 comments

Comments

@tailhook
Copy link

Hi,

Is there any way to debug where trap happened? At least function would be good, file+line and/or traceback is even better.

I'm using rust's wasm32-unknown-unknown for generating wasm code itself (and the trap is a panic). Maybe that's something to tweak at the compiler side?

@pepyakin
Copy link
Collaborator

In general, there is no way to get location of the trap yet (although this should be very useful, and I think this is somwthing we want sooner rather than later)

However, it is possible to print information provided in panic payload, at least if you have a custom panic fmt. But im not sure how panics are reported in wasm32-unknown-unknown with std.

@tailhook
Copy link
Author

However, it is possible to print information provided in panic payload, at least if you have a custom panic fmt. But im not sure how panics are reported in wasm32-unknown-unknown with std.

It looks like payload is ignored by rust compiler: https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/wasm32.rs#L28

Also, what do you mean by "print"? I don't think there is some builtin way to print something in wasm.

@pepyakin
Copy link
Collaborator

pepyakin commented Jan 29, 2018

AFAIK, actual printing happens in the panic hook, ie here which happens before libpanic_* takes control (just take a look at other impls or at libpanic_abort).

Also, what do you mean by "print"? I don't think there is some builtin way to print something in wasm.

Yeah, you're right! However, in some envs such as web JS or wasmi we can define what it means to print something.

And, In fact, wasm std lib supports basic i/o however under special flag DEBUG

Hope this helps!

@tailhook
Copy link
Author

Wow, that worked like a charm! Thanks. Here is the code that catches panics and logs payload and location for anyone trying to figure it out.

However, I think this issue (i.e. tracking traps and not only panics out of the box) depends on debugging symbols and should not be closed yet. Right?

@pepyakin
Copy link
Collaborator

Im very happy thats worked!

And yea, you right, we still need to have means to debug different kinds of traps and print stacktraces. And yeah it depends on debugging symbols (although plain name section should do the trick for the start)

@pepyakin pepyakin mentioned this issue Feb 5, 2018
@Robbepop Robbepop changed the title Debugging traps Add origin information about Wasm traps Aug 22, 2022
@Robbepop
Copy link
Member

Closed in favor of #538.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants