Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions src/wamr/wamr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,9 @@ void Wamr::getModuleFunctionImpl(std::string_view function_name,
if (trap) {
WasmByteVec error_message;
wasm_trap_message(trap.get(), error_message.get());
std::string message(error_message.get()->data); // NULL-terminated
fail(FailState::RuntimeError,
"Function: " + std::string(function_name) + " failed:\n" +
std::string(error_message.get()->data, error_message.get()->size));
"Function: " + std::string(function_name) + " failed: " + message);
return;
}
if (log) {
Expand Down Expand Up @@ -628,9 +628,9 @@ void Wamr::getModuleFunctionImpl(std::string_view function_name,
if (trap) {
WasmByteVec error_message;
wasm_trap_message(trap.get(), error_message.get());
std::string message(error_message.get()->data); // NULL-terminated
fail(FailState::RuntimeError,
"Function: " + std::string(function_name) + " failed:\n" +
std::string(error_message.get()->data, error_message.get()->size));
"Function: " + std::string(function_name) + " failed: " + message);
return R{};
}
R ret = convertValueTypeToArg<R>(results.data[0]);
Expand Down
8 changes: 4 additions & 4 deletions src/wasmedge/wasmedge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,8 @@ void WasmEdge::getModuleFunctionImpl(std::string_view function_name,
WasmEdge_Result res =
WasmEdge_ExecutorInvoke(executor_.get(), func_cxt, params, sizeof...(Args), nullptr, 0);
if (!WasmEdge_ResultOK(res)) {
fail(FailState::RuntimeError, "Function: " + std::string(function_name) + " failed:\n" +
WasmEdge_ResultGetMessage(res));
fail(FailState::RuntimeError, "Function: " + std::string(function_name) +
" failed: " + WasmEdge_ResultGetMessage(res));
return;
}
if (log) {
Expand Down Expand Up @@ -594,8 +594,8 @@ void WasmEdge::getModuleFunctionImpl(std::string_view function_name,
WasmEdge_Result res =
WasmEdge_ExecutorInvoke(executor_.get(), func_cxt, params, sizeof...(Args), results, 1);
if (!WasmEdge_ResultOK(res)) {
fail(FailState::RuntimeError, "Function: " + std::string(function_name) + " failed:\n" +
WasmEdge_ResultGetMessage(res));
fail(FailState::RuntimeError, "Function: " + std::string(function_name) +
" failed: " + WasmEdge_ResultGetMessage(res));
return R{};
}
R ret = convValTypeToArg<R>(results[0]);
Expand Down
8 changes: 4 additions & 4 deletions src/wasmtime/wasmtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,9 @@ void Wasmtime::getModuleFunctionImpl(std::string_view function_name,
if (trap) {
WasmByteVec error_message;
wasm_trap_message(trap.get(), error_message.get());
std::string message(error_message.get()->data); // NULL-terminated
fail(FailState::RuntimeError,
"Function: " + std::string(function_name) + " failed:\n" +
std::string(error_message.get()->data, error_message.get()->size));
"Function: " + std::string(function_name) + " failed: " + message);
return;
}
if (log) {
Expand Down Expand Up @@ -678,9 +678,9 @@ void Wasmtime::getModuleFunctionImpl(std::string_view function_name,
if (trap) {
WasmByteVec error_message;
wasm_trap_message(trap.get(), error_message.get());
std::string message(error_message.get()->data); // NULL-terminated
fail(FailState::RuntimeError,
"Function: " + std::string(function_name) + " failed:\n" +
std::string(error_message.get()->data, error_message.get()->size));
"Function: " + std::string(function_name) + " failed: " + message);
return R{};
}
R ret = convertValueTypeToArg<R>(results.data[0]);
Expand Down
28 changes: 22 additions & 6 deletions test/runtime_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ TEST_P(TestVm, TerminateExecution) {
// Check integration logs.
auto *host = dynamic_cast<TestIntegration *>(wasm.wasm_vm()->integration().get());
EXPECT_TRUE(host->isErrorLogged("Function: infinite_loop failed"));
if (engine_ == "v8") {
EXPECT_TRUE(host->isErrorLogged("Uncaught Error: termination_exception"));
}
EXPECT_TRUE(host->isErrorLogged("termination_exception"));
}

TEST_P(TestVm, WasmMemoryLimit) {
Expand All @@ -135,8 +133,14 @@ TEST_P(TestVm, WasmMemoryLimit) {
// Check integration logs.
auto *host = dynamic_cast<TestIntegration *>(wasm.wasm_vm()->integration().get());
EXPECT_TRUE(host->isErrorLogged("Function: infinite_memory failed"));
// Trap message
if (engine_ == "wavm") {
EXPECT_TRUE(host->isErrorLogged("wavm.reachedUnreachable"));
} else {
EXPECT_TRUE(host->isErrorLogged("unreachable"));
}
// Backtrace
if (engine_ == "v8") {
EXPECT_TRUE(host->isErrorLogged("Uncaught RuntimeError: unreachable"));
EXPECT_TRUE(host->isErrorLogged("Proxy-Wasm plugin in-VM backtrace:"));
EXPECT_TRUE(host->isErrorLogged(" - rust_oom"));
EXPECT_TRUE(host->isErrorLogged(" - alloc::alloc::handle_alloc_error"));
Expand All @@ -158,8 +162,14 @@ TEST_P(TestVm, Trap) {
// Check integration logs.
auto *host = dynamic_cast<TestIntegration *>(wasm.wasm_vm()->integration().get());
EXPECT_TRUE(host->isErrorLogged("Function: trigger failed"));
// Trap message
if (engine_ == "wavm") {
EXPECT_TRUE(host->isErrorLogged("wavm.reachedUnreachable"));
} else {
EXPECT_TRUE(host->isErrorLogged("unreachable"));
}
// Backtrace
if (engine_ == "v8") {
EXPECT_TRUE(host->isErrorLogged("Uncaught RuntimeError: unreachable"));
EXPECT_TRUE(host->isErrorLogged("Proxy-Wasm plugin in-VM backtrace:"));
EXPECT_TRUE(host->isErrorLogged(" - std::panicking::begin_panic"));
EXPECT_TRUE(host->isErrorLogged(" - trigger"));
Expand All @@ -181,8 +191,14 @@ TEST_P(TestVm, Trap2) {
// Check integration logs.
auto *host = dynamic_cast<TestIntegration *>(wasm.wasm_vm()->integration().get());
EXPECT_TRUE(host->isErrorLogged("Function: trigger2 failed"));
// Trap message
if (engine_ == "wavm") {
EXPECT_TRUE(host->isErrorLogged("wavm.reachedUnreachable"));
} else {
EXPECT_TRUE(host->isErrorLogged("unreachable"));
}
// Backtrace
if (engine_ == "v8") {
EXPECT_TRUE(host->isErrorLogged("Uncaught RuntimeError: unreachable"));
EXPECT_TRUE(host->isErrorLogged("Proxy-Wasm plugin in-VM backtrace:"));
EXPECT_TRUE(host->isErrorLogged(" - std::panicking::begin_panic"));
EXPECT_TRUE(host->isErrorLogged(" - trigger2"));
Expand Down