From a304cdac034d9438fd0638a7a264e235461d2985 Mon Sep 17 00:00:00 2001 From: Patrick Ventuzelo Date: Wed, 2 Oct 2019 17:23:11 +0200 Subject: [PATCH 1/4] replace expect with map_err --- src/bin/wasmer.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 14d3caf2658..a341e9f2bb3 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -525,20 +525,21 @@ fn execute_wasm(options: &Run) -> Result<(), String> { args.push(Value::I32(x)); } - let index = instance - .resolve_func("_start") - .expect("The loader requires a _start function to be present in the module"); + let index = instance.resolve_func("_start").map_err(|_| { + format!("The loader requires a _start function to be present in the module") + })?; + let mut ins: Box> = match loader { LoaderName::Local => Box::new( instance .load(LocalLoader) - .expect("Can't use the local loader"), + .map_err(|e| format!("Can't use the local loader: {:?}", e))?, ), #[cfg(feature = "loader-kernel")] LoaderName::Kernel => Box::new( instance .load(::wasmer_kernel_loader::KernelLoader) - .expect("Can't use the kernel loader"), + .map_err(|e| format!("Can't use the local loader: {:?}", e))?, ), }; println!("{:?}", ins.call(index, &args)); @@ -610,7 +611,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> { f.read_to_end(&mut out).unwrap(); Some( wasmer_runtime_core::state::InstanceImage::from_bytes(&out) - .expect("failed to decode image"), + .map_err(|_| format!("failed to decode image"))?, ) } else { None From e1c26b1932c4d63bbeb68cb6023d060c5b4ad581 Mon Sep 17 00:00:00 2001 From: Patrick Ventuzelo Date: Wed, 2 Oct 2019 17:32:35 +0200 Subject: [PATCH 2/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4612f570425..f67b460f6d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Blocks of changes will separated by version increments. ## **[Unreleased]** +- [#858](https://github.com/wasmerio/wasmer/pull/858) Fix panic when `loader` option associated with wasm module without exported `_start` function - [#852](https://github.com/wasmerio/wasmer/pull/852) Make minor grammar/capitalization fixes to README.md - [#841](https://github.com/wasmerio/wasmer/pull/841) Slightly improve rustdoc documentation and small updates to outdated info in readme files - [#835](https://github.com/wasmerio/wasmer/pull/836) Update Cranelift fork version to `0.44.0` From 6b09abb2fdd173319fcde4376d94530c649ce859 Mon Sep 17 00:00:00 2001 From: Patrick Ventuzelo Date: Thu, 3 Oct 2019 09:18:27 +0200 Subject: [PATCH 3/4] make changelog more clear --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f67b460f6d1..2be104f50a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Blocks of changes will separated by version increments. ## **[Unreleased]** -- [#858](https://github.com/wasmerio/wasmer/pull/858) Fix panic when `loader` option associated with wasm module without exported `_start` function +- [#858](https://github.com/wasmerio/wasmer/pull/858) Minor panic fix when wasmer binary with `loader` option run a module without exported `_start` function - [#852](https://github.com/wasmerio/wasmer/pull/852) Make minor grammar/capitalization fixes to README.md - [#841](https://github.com/wasmerio/wasmer/pull/841) Slightly improve rustdoc documentation and small updates to outdated info in readme files - [#835](https://github.com/wasmerio/wasmer/pull/836) Update Cranelift fork version to `0.44.0` From 3836b544b62f22a6bfb8df268a221ccd4fe7683f Mon Sep 17 00:00:00 2001 From: Patrick Ventuzelo <9038181+pventuzelo@users.noreply.github.com> Date: Wed, 11 Dec 2019 10:46:42 +0100 Subject: [PATCH 4/4] update changelog --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e92f951ce7..04cf0ae3230 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#858](https://github.com/wasmerio/wasmer/pull/858) Minor panic fix when wasmer binary with `loader` option run a module without exported `_start` function. - [#1056](https://github.com/wasmerio/wasmer/pull/1056) Improved `--invoke` args parsing (supporting `i32`, `i64`, `f32` and `f32`) in Wasmer CLI - [#1054](https://github.com/wasmerio/wasmer/pull/1054) Improve `--invoke` output in Wasmer CLI - [#1053](https://github.com/wasmerio/wasmer/pull/1053) For RuntimeError and breakpoints, use Box instead of Box. @@ -62,8 +63,6 @@ Special thanks to @alocquet for their contributions! - [#897](https://github.com/wasmerio/wasmer/pull/897) Removes special casing of stdin, stdout, and stderr in WASI. Closing these files now works. Removes `stdin`, `stdout`, and `stderr` from `WasiFS`, replaced by the methods `stdout`, `stdout_mut`, and so on. - [#863](https://github.com/wasmerio/wasmer/pull/863) Fix min and max for cases involving NaN and negative zero when using the LLVM backend. -- [#858](https://github.com/wasmerio/wasmer/pull/858) Minor panic fix when wasmer binary with `loader` option run a module without exported `_start` function - ## 0.8.0 - 2019-10-02 Special thanks to @jdanford for their contributions!