From 5996ed9c69c3436119ae41cce34f6d4ee28cd3e8 Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Thu, 10 Feb 2022 15:33:34 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9D=9F=8E=20only=20log=20non-zero=20exit=20s?= =?UTF-8?q?tatus=20codes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 - !__wasi_proc_exit 1: 0x280f6 - !_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. --- lib/src/execute.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/execute.rs b/lib/src/execute.rs index fe969fae..e01971aa 100644 --- a/lib/src/execute.rs +++ b/lib/src/execute.rs @@ -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) });