From e0a449672a372aced4d11b4d60a49293d413a9bb Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Mon, 3 Feb 2020 14:41:37 -0800 Subject: Trap when call_indirect's signatures mismatch (#2636) This makes the interpreter trap when the signature in `call_indirect` instruction and that of the actual function in the table mismatch. This also makes the `wasm-ctor-eval` not evaluate `call_indirect` in case the signatures mismatch. Before we only compared the arguments' signature and the function signature, which was sufficient before we had subtypes, but now the signature in `call_indirect` and that of the actual function can be different even if the argument's signature is OK. --- src/tools/wasm-ctor-eval.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/tools/wasm-ctor-eval.cpp') diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index b45c624a4..3aef10cf0 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -215,6 +215,7 @@ struct CtorEvalExternalInterface : EvallingModuleInstance::ExternalInterface { } Literal callTable(Index index, + Signature sig, LiteralList& arguments, Type result, EvallingModuleInstance& instance) override { @@ -240,6 +241,10 @@ struct CtorEvalExternalInterface : EvallingModuleInstance::ExternalInterface { // if this is one of our functions, we can call it; if it was imported, // fail auto* func = wasm->getFunction(name); + if (func->sig != sig) { + throw FailToEvalException( + std::string("callTable signature mismatch: ") + name.str); + } if (!func->imported()) { return instance.callFunctionInternal(name, arguments); } else { -- cgit v1.2.3