Skip to content

Commit

Permalink
𝟎 only log non-zero exit status codes
Browse files Browse the repository at this point in the history
if a program invokes e.g., `std::process:exit(0)`, this should not cause
confusing diagnostic messages as reported in #127:

```
  Jan 1 00:00:00.123 ERROR viceroy_lib::execute: WebAssembly trapped: Exited with i32 exit status 0
wasm backtrace:
    0: 0x280ea - <unknown>!__wasi_proc_exit
    1: 0x280f6 - <unknown>!_Exit
```

this is unfortunately difficult to test, because the
`Result<(), ExecutionError>` of `ExecuteCtx::run_guest` is spawned in a
task that we do not join on later. (note: that is intentional)

the alternative of a test that checks for a particular log message felt
brittle, and this is a relatively straightfoward change.
  • Loading branch information
katelyn martin committed Feb 11, 2022
1 parent 8b96b78 commit 5996ed9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ impl ExecuteCtx {
.await
.map(|_| ())
.map_err(|trap| {
event!(Level::ERROR, "WebAssembly trapped: {}", trap);
// Be sure that we only log non-zero status codes.
if trap.i32_exit_status() != Some(0) {
event!(Level::ERROR, "WebAssembly trapped: {}", trap);
}
ExecutionError::WasmTrap(trap)
});

Expand Down

0 comments on commit 5996ed9

Please sign in to comment.