Skip to content
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

[fix 857] panic when target module don't have exported _start function #858

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
pventuzelo marked this conversation as resolved.
Show resolved Hide resolved
- [#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`
Expand Down
13 changes: 7 additions & 6 deletions src/bin/wasmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn LoadedInstance<Error = String>> = 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));
Expand Down Expand Up @@ -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
Expand Down