Preserve full native stack traces in errors (#823)
* Preserve full native stack traces in errors This commit builds on #759 by performing a few refactorings: * The `backtrace` crate is updated to 0.3.42 which incorporates the Windows-specific stack-walking code, so that's no longer needed. * A full `backtrace::Backtrace` type is held in a trap at all times. * The trap structures in the `wasmtime-*` internal crates were refactored a bit to preserve more information and deal with raw values rather than converting between various types and strings. * The `wasmtime::Trap` type has been updated with these various changes. Eventually I think we'll want to likely render full stack traces (and/or partial wasm ones) into error messages, but for now that's left as-is and we can always improve it later. I suspect the most relevant thing we need to do is to implement function name symbolication for wasm functions first, and then afterwards we can incorporate native function names! * Fix some test suite assertions
This commit is contained in:
@@ -6,10 +6,7 @@ use std::cmp::max;
|
||||
use std::{fmt, mem, ptr, slice};
|
||||
use thiserror::Error;
|
||||
use wasmtime_environ::ir;
|
||||
use wasmtime_runtime::{
|
||||
wasmtime_call_trampoline, Backtrace, Export, InstanceHandle, TrapMessageAndStack,
|
||||
VMInvokeArgument,
|
||||
};
|
||||
use wasmtime_runtime::{wasmtime_call_trampoline, Export, InstanceHandle, Trap, VMInvokeArgument};
|
||||
|
||||
/// A runtime value.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
@@ -103,12 +100,7 @@ pub enum ActionOutcome {
|
||||
},
|
||||
|
||||
/// A trap occurred while the action was executing.
|
||||
Trapped {
|
||||
/// The trap message.
|
||||
message: String,
|
||||
/// Backtrace.
|
||||
trace: Backtrace,
|
||||
},
|
||||
Trapped(Trap),
|
||||
}
|
||||
|
||||
/// An error detected while invoking a wasm function or reading a wasm global.
|
||||
@@ -196,7 +188,7 @@ pub fn invoke(
|
||||
compiler.publish_compiled_code();
|
||||
|
||||
// Call the trampoline.
|
||||
if let Err(TrapMessageAndStack(message, trace)) = unsafe {
|
||||
if let Err(trap) = unsafe {
|
||||
instance.with_signals_on(|| {
|
||||
wasmtime_call_trampoline(
|
||||
callee_vmctx,
|
||||
@@ -205,7 +197,7 @@ pub fn invoke(
|
||||
)
|
||||
})
|
||||
} {
|
||||
return Ok(ActionOutcome::Trapped { message, trace });
|
||||
return Ok(ActionOutcome::Trapped(trap));
|
||||
}
|
||||
|
||||
// Load the return values out of `values_vec`.
|
||||
|
||||
Reference in New Issue
Block a user