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 for Wasm Coredump #3578

Open
xtuc opened this issue Feb 7, 2023 · 14 comments
Open

Support for Wasm Coredump #3578

xtuc opened this issue Feb 7, 2023 · 14 comments
Assignees
Labels
🎉 enhancement New feature! priority-low Low priority issue
Milestone

Comments

@xtuc
Copy link
Contributor

xtuc commented Feb 7, 2023

Motivation

When the Wasm instance traps, it's sometimes difficult to understand what happened. Post-mortem debugging using coredumps (which is extensively used in native environment) would be helpful for investigating and fixing crashes.

Demo from a developer's point of view: https://github.com/xtuc/wasmgdb/wiki/Demo.

Proposed solution

Implement Wasm coredumps as specified by https://github.com/WebAssembly/tool-conventions/blob/main/Coredump.md. Note that the spec is early and subject to changes. Feedback very welcome!

Additional context

Wasm coredump is especially useful for serverless environment where production binaries are stripped and/or have access to limited logging.

@xtuc xtuc added the 🎉 enhancement New feature! label Feb 7, 2023
@ptitSeb ptitSeb added this to the v3.x milestone Feb 14, 2023
@ptitSeb ptitSeb added the priority-low Low priority issue label Feb 14, 2023
@ptitSeb ptitSeb self-assigned this Feb 14, 2023
@syrusakbary
Copy link
Member

Hey @xtuc , thanks for opening the issue.

We would love to support wasm coredumps, but we are a bit constrained on resources.
However, if you would like to help us on that quest we would be more than welcome to accept any improvements/patches towards that goal!

@xtuc
Copy link
Contributor Author

xtuc commented Feb 23, 2023

@syrusakbary I will give it a try. I believe I can use the Backtrace information when a RuntimeError and/or Trap occurs.
This should give us a initial / basic coredump implementation.

Please free to send any other pointers if you have something in mind.

@syrusakbary
Copy link
Member

Awesome, I believe RuntimeError and backtrace info as you mentioned should make wasm coredump possible.

If you have any questions upon implementing things please let us know on this thread and we will assist!

xtuc added a commit to xtuc/wasmer that referenced this issue Feb 24, 2023
This change adds a basic coredump generation after a WebAssembly trap
was entered. The coredump includes rudimentary stack / process debugging
information.

A new CLI argument is added to enable coredump generation:

```
wasmtime --coredump-on-trap=/path/to/coredump/file module.wasm
```

Refs wasmerio#3578
xtuc added a commit to xtuc/wasmer that referenced this issue Feb 24, 2023
This change adds a basic coredump generation after a WebAssembly trap
was entered. The coredump includes rudimentary stack / process debugging
information.

A new CLI argument is added to enable coredump generation:

```
wasmer --coredump-on-trap=/path/to/coredump/file module.wasm
```

Refs wasmerio#3578
xtuc added a commit to xtuc/wasmer that referenced this issue Feb 24, 2023
This change adds a basic coredump generation after a WebAssembly trap
was entered. The coredump includes rudimentary stack / process debugging
information.

A new CLI argument is added to enable coredump generation:

```
wasmer --coredump-on-trap=/path/to/coredump/file module.wasm
```

Refs wasmerio#3578
@xtuc
Copy link
Contributor Author

xtuc commented Feb 24, 2023

@syrusakbary I opened #3626 for adding basic coredump generation using the existing APIs.

It's inpired by the change I did for wasmtime and wrote some documentation: https://github.com/bytecodealliance/wasmtime/blob/db931d7a93208738b8106e8d8c1a4afc8efaca6d/docs/examples-coredump.md.

xtuc added a commit to xtuc/wasmer that referenced this issue Feb 24, 2023
This change adds a basic coredump generation after a WebAssembly trap
was entered. The coredump includes rudimentary stack / process debugging
information.

A new CLI argument is added to enable coredump generation:

```
wasmer --coredump-on-trap=/path/to/coredump/file module.wasm
```

Refs wasmerio#3578
xtuc added a commit to xtuc/wasmer that referenced this issue Feb 27, 2023
This change adds a basic coredump generation after a WebAssembly trap
was entered. The coredump includes rudimentary stack / process debugging
information.

A new CLI argument is added to enable coredump generation:

```
wasmer --coredump-on-trap=/path/to/coredump/file module.wasm
```

See docs/en/examples-coredump.md.

Refs wasmerio#3578
xtuc added a commit to xtuc/wasmer that referenced this issue Feb 27, 2023
This change adds a basic coredump generation after a WebAssembly trap
was entered. The coredump includes rudimentary stack / process debugging
information.

A new CLI argument is added to enable coredump generation:

```
wasmer --coredump-on-trap=/path/to/coredump/file module.wasm
```

See docs/en/examples-coredump.md.

Refs wasmerio#3578
@xtuc
Copy link
Contributor Author

xtuc commented Feb 28, 2023

Basic coredump generation has been merged (thanks!).

Now, to have the complete debugger experience, we need to collect the following information:

  • Wasm locals of each stack frames; when discussing with wasmtime and having a look at the code myself, support in cranelift is going to take a significant effort. Would the implementation in the LLVM backend be easier for wasmer?
  • Snapshot the Wasm instance memory; sounds relatively easy.

@syrusakbary
Copy link
Member

syrusakbary commented Feb 28, 2023

Would the implementation in the LLVM backend be easier for wasmer?

Probably. In the past (wasmer 0.x) we used LLVM stack maps for tracking traps, so I believe it shall be doable

@syrusakbary
Copy link
Member

Probably @ptitSeb can chime in with more thoughts here

@ptitSeb
Copy link
Contributor

ptitSeb commented Feb 28, 2023

I guess we are talking about tracking the locals in eh_frame/dwarf stuff. I would like to work on something like that yes, but I'll probably start on the singleplass, because this is were I have the more control.
It might be easy on LLVM, but I don't know the whole API well enough to say for now.

@ptitSeb
Copy link
Contributor

ptitSeb commented May 3, 2023

PR merged, closing.

@ptitSeb ptitSeb closed this as completed May 3, 2023
@xtuc
Copy link
Contributor Author

xtuc commented May 3, 2023

The merged PR only has a limited support to Wasmer, most of the features aren't implemented because we are missing access to locals and main memory.

@syrusakbary
Copy link
Member

Should we keep the issue open then @xtuc? Would you like to work on the missing features?

@xtuc
Copy link
Contributor Author

xtuc commented May 5, 2023

@syrusakbary I'm not familiar enough to do it myself

@syrusakbary syrusakbary reopened this May 5, 2023
Copy link

stale bot commented May 4, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the 🏚 stale Inactive issues or PR label May 4, 2024
@theduke
Copy link
Contributor

theduke commented May 6, 2024

Not stale.

@stale stale bot removed the 🏚 stale Inactive issues or PR label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 enhancement New feature! priority-low Low priority issue
Projects
None yet
Development

No branches or pull requests

4 participants