Skip to content

Commit

Permalink
fix(trap): remove the duplicated panicking function in call stack
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop authored and atenjin committed Jun 2, 2021
1 parent 22fd27e commit c0b7a80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl FuncInstance {
if let Some(info) = n {
format!("{:#}[{}]", rustc_demangle::demangle(&info.1), info.0)
} else {
"unknown".to_string()
"<unknown>".to_string()
}
})
.collect::<Vec<_>>();
Expand Down
13 changes: 3 additions & 10 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,26 +320,19 @@ impl Interpreter {
nested_func.signature().return_type(),
);
}
return Err(
trap.wasm_trace_with(function_ref.clone().info())
);
return Err(trap);
}
};

// Check if `return_val` matches the signature.
let value_ty = return_val.as_ref().map(|val| val.value_type());
let expected_ty = nested_func.signature().return_type();
if value_ty != expected_ty {
return Err(Trap::wasm_trace_with_kind(
TrapKind::StackOverflow,
function_ref.clone().info(),
));
return Err(TrapKind::StackOverflow.into());
}

if let Some(return_val) = return_val {
self.value_stack.push(return_val.into()).map_err(|trap| {
Trap::wasm_trace_with_kind(trap, function_ref.clone().info())
})?;
self.value_stack.push(return_val.into())?;
}
}
}
Expand Down

0 comments on commit c0b7a80

Please sign in to comment.