-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 core dump support to the runtime #6513
Conversation
Subscribe to Label Actioncc @peterhuene
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:config"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Label Messager: wasmtime:configIt looks like you are changing Wasmtime's configuration options. Make sure to
To modify this label's message, edit the To add new label messages or remove existing label messages, edit the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good!
Before this can land, we still need some smoke tests under tests/all/coredump.rs
though. Should test that we get the expected stack, modules, instances, globals, and memories in the resulting coredumps.
To be explicit, mostly for folks following along at home, I'm okay with waiting for follow up PRs to implement
- serialization into the Wasm coredump format for
wastime::WasmCoreDump
- implementing
wasmtime --coredump-on-trap=...
in the CLI on top ofwasmtime::WasmCoreDump
.
A few nitpicks inline below.
Thanks!
853a375
to
e486f55
Compare
aa80bd1
to
98aea80
Compare
@fitzgen I added some smoke tests though I am still trying to figure out why exported Globals and Memories aren't getting included in the CoreDump. Also in order to downcast the anyhow error to a WasmCoreDump, it needs to |
Ah, I think it would actually be better to make a custom impl std::fmt::Debug for WasmCoreDump {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "<wasm core dump>")
}
} This avoids needing to do |
7fb2fbf
to
9ee6f87
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Feel free to enqueue to merge when this is rebased and conflicts are resolved.
This adds the machinery to capture a core dump when a trap occurs and attach it to the resulting anyhow::Error that gets bubbled up to the caller. I've created a CoreDumpStack structure in the runtime, which is currently just a backtrace until we design a way to recover the locals stack values when a trap occurs. When that CoreDumpStack gets converted to a wasmtime::WasmCoreDump, we add additional information from the Store such as globals, memories, and instance information. A lot of this is mechanistically similar to how backtraces are captured and attached to errors. Given that they both are attached as context to anyhow::Errors, setting coredump_on_trap to true will supercede any setting for wasm_backtrace.
9ee6f87
to
77b8cf2
Compare
* main: (47 commits) Add core dump support to the runtime (bytecodealliance#6513) Resource table tracks child relationships (bytecodealliance#6779) Wasmtime: Move `OnDemandInstanceAllocator` to its own module (bytecodealliance#6790) wasi: Test the stdio streams implementation (bytecodealliance#6764) Don't generate same-named imports in fact modules (bytecodealliance#6783) Wasmtime: Add support for Wasm tail calls (bytecodealliance#6774) Cranelift: Fix `ABIMachineSpec::gen_add_imm` for riscv64 (bytecodealliance#6780) Update the wasm-tools family of crates, disallow empty component types (bytecodealliance#6777) Fix broken link to WASI API documentation (bytecodealliance#6775) A bunch of cleanups for cranelift-codegen-meta (bytecodealliance#6772) Implement component-to-component calls with resources (bytecodealliance#6769) Ignore async_stack_size if async_support is disabled (bytecodealliance#6771) A bunch of minor cleanups (bytecodealliance#6767) Fix flaky tests in preview2 streams (bytecodealliance#6763) Refactor and simplify component trampolines (bytecodealliance#6751) Cranelift: Implement tail calls on riscv64 (bytecodealliance#6749) WASI Preview 2: rewrite streams and pollable implementation (bytecodealliance#6556) cranelift-wasm: Add support for translating Wasm tail calls to CLIF (bytecodealliance#6760) Cranelift: Get tail calls working on aarch64 (bytecodealliance#6723) Implement component model resources in Wasmtime (bytecodealliance#6691) ...
* Add config method for whether or not to capture coredumps on trap * Add core dump support to the runtime This adds the machinery to capture a core dump when a trap occurs and attach it to the resulting anyhow::Error that gets bubbled up to the caller. I've created a CoreDumpStack structure in the runtime, which is currently just a backtrace until we design a way to recover the locals stack values when a trap occurs. When that CoreDumpStack gets converted to a wasmtime::WasmCoreDump, we add additional information from the Store such as globals, memories, and instance information. A lot of this is mechanistically similar to how backtraces are captured and attached to errors. Given that they both are attached as context to anyhow::Errors, setting coredump_on_trap to true will supercede any setting for wasm_backtrace. * Address some PR feedback * Fix docs * Switch WasmCoreDump to have vec of module names rather than Modules * Add smoketests for WasmCoreDump * clean up tests * Update memories and globals field to be store_ * add debug impl for wasmcoredump * Remove duplicate imports * ignore miri for wasm tests
This adds a configuration option and machinery to capture a core dump when
a trap occurs and attach it to the resulting anyhow::Error that gets bubbled up to
the caller. I've created a CoreDumpStack structure in the runtime, which is
currently just a backtrace until we design a way to recover the locals and
stack values when a trap occurs. When that CoreDumpStack gets converted to
a wasmtime::WasmCoreDump, we add additional information from the Store such
as globals, memories, and instance information.
A lot of this is mechanistically similar to how backtraces
are captured and attached to errors. Given that they both are attached as
context to anyhow::Errors, setting coredump_on_trap to true will supersede
any setting for wasm_backtrace.