-
Notifications
You must be signed in to change notification settings - Fork 141
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
deps: Update wasmtime to v4.0.0 #1412
Conversation
Update - The last commit reduces the number of errors which appear in the build output, but I can't tell if this is because things got more or less broken Most of this mess is caused by changes in this wasmtime commit - bytecodealliance/wasmtime@2afaac5 Essentially wasmtime Traps are now a simple enum, but it's now possible to return any error types we want from syscalls and, IIUC, we just get them back from So in theory:
|
Ok, I think I fixed it. We'll see if the tests pass. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1412 +/- ##
===========================================
+ Coverage 53.33% 70.77% +17.44%
===========================================
Files 141 97 -44
Lines 13122 7561 -5561
===========================================
- Hits 6998 5351 -1647
+ Misses 6124 2210 -3914
|
Ok, so, one error down but... I have no idea how to detect "out of memory" on initialization. We used to be able to do this, but it looks like the error types just disappeared. Options are:
Honestly, the last one is probably the simplest. It's not great, but... We should probably write a test to see what error wasmtime gives us because there may be some error type that I'm missing. |
}, | ||
Err(e) => Abort::Fatal(e), | ||
.map_err(|e| { | ||
// todo try to distinguish resource limit / trap / fatal |
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.
Todo
#[allow(deprecated)] // TODO https://github.com/bytecodealliance/wasmtime/issues/5037 | ||
// has to be enabled, otherwise returning errors from syscalls will not work | ||
c.wasm_backtrace(true); |
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.
With c.wasm_backtrace(false)
tests fail with
---- events_test stdout ----
thread 'events_test' panicked at 'assertion failed: needs_backtrace == backtrace.is_some()', /home/magik6k/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmtime-4.0.0/src/trap.rs:101:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'events_test' panicked at 'assertion failed: needs_backtrace == backtrace.is_some()', /home/magik6k/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmtime-4.0.0/src/trap.rs:101:13
thread 'events_test' panicked at 'assertion failed: needs_backtrace == backtrace.is_some()', /home/magik6k/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmtime-4.0.0/src/trap.rs:101:13
thread 'events_test' panicked at 'assertion failed: needs_backtrace == backtrace.is_some()', /home/magik6k/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmtime-4.0.0/src/trap.rs:101:13
thread 'events_test' panicked at 'assertion failed: needs_backtrace == backtrace.is_some()', /home/magik6k/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmtime-4.0.0/src/trap.rs:101:13
thread 'events_test' panicked at 'assertion failed: needs_backtrace == backtrace.is_some()', /home/magik6k/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmtime-4.0.0/src/trap.rs:101:13
thread 'events_test' panicked at 'assertion failed: `(left == right)`
left: `ExitCode { value: 0 }`,
right: `ExitCode { value: 10 }`', testing/integration/tests/events_test.rs:105:5
Which fails an assert in this code:
store: &StoreOpaque,
runtime_trap: Box<wasmtime_runtime::Trap>,
) -> Error {
let wasmtime_runtime::Trap { reason, backtrace } = *runtime_trap;
let (error, pc) = match reason {
// For user-defined errors they're already an `anyhow::Error` so no
// conversion is really necessary here, but a `backtrace` may have
// been captured so it's attempted to get inserted here.
//
// If the error is actually a `Trap` then the backtrace is inserted
// directly into the `Trap` since there's storage there for it.
// Otherwise though this represents a host-defined error which isn't
// using a `Trap` but instead some other condition that was fatal to
// wasm itself. In that situation the backtrace is inserted as
// contextual information on error using `error.context(...)` to
// provide useful information to debug with for the embedder/caller,
// otherwise the information about what the wasm was doing when the
// error was generated would be lost.
wasmtime_runtime::TrapReason::User {
error,
needs_backtrace,
} => {
debug_assert!(needs_backtrace == backtrace.is_some()); ******************This assert fails****************
(error, None)
}
wasmtime_runtime::TrapReason::Jit(pc) => {
let code = store
.modules()
.lookup_trap_code(pc)
.unwrap_or(Trap::StackOverflow);
(code.into(), Some(pc))
}
wasmtime_runtime::TrapReason::Wasm(trap_code) => (trap_code.into(), None),
};
match backtrace {
Some(bt) => {
let bt = WasmBacktrace::from_captured(store, bt, pc);
if bt.wasm_trace.is_empty() {
error
} else {
error.context(bt)
}
}
None => error,
}
}
Most likely due to a trap being generated that needs a backtrace, but none being captured due to backtraces being disabled; And because wasmtime wants to deprecate the option to disable backtraces it's probably unlikely that they'll fix this
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.
user errors when returned have needs_backtrace set to true:
- https://github.com/bytecodealliance/wasmtime/blob/main/crates/runtime/src/traphandlers.rs#L160-L164
- https://github.com/bytecodealliance/wasmtime/blob/main/crates/runtime/src/traphandlers.rs#L181-L185
With seemingly no way to tell wasmtime that we really don't care about that backtrace
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.
Unfortunately enabling backtraces makes native_stack_overflow take 13 minutes on my machine.
The native_stack_overflow test is invoking an actor which:
- Makes 396 recursive calls inside wasm to fill the entire wasm stack limit
- Then calls itself recursively until we hit recursive call limit
This test was written to ensure that in the most extreme abuse wasm actors can't exhaust native stacks, as that fault can't be caught / handled safely in any way. So why is this so slow? Didn't wasmtime fix backtrace re-capture in 3.0.0 (bytecodealliance/wasmtime#5037)? They did.. but when we return from a failed actor send syscall, we're returning a new user error, for which wasmtime will re-capture backtrace again..Ideally we'd have a way to tell wasmtime that we don't want to capture a backtrace when returning from syscalls, but I don't see a way today
Wasmtime issue about backtrace error bug: bytecodealliance/wasmtime#5577 |
Replaced by #1672 |
Doesn't build yet because error handling hates me