summaryrefslogtreecommitdiff
path: root/src/tools/wasm-ctor-eval.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2020-02-03 14:41:37 -0800
committerGitHub <noreply@github.com>2020-02-03 14:41:37 -0800
commite0a449672a372aced4d11b4d60a49293d413a9bb (patch)
tree4b3879c08c8fbfddf38d8092bdac99c6ffb5f9a2 /src/tools/wasm-ctor-eval.cpp
parentc9f2e9b7b24182e830f39c176170d5ca64d3d05e (diff)
downloadbinaryen-e0a449672a372aced4d11b4d60a49293d413a9bb.tar.gz
binaryen-e0a449672a372aced4d11b4d60a49293d413a9bb.tar.bz2
binaryen-e0a449672a372aced4d11b4d60a49293d413a9bb.zip
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.
Diffstat (limited to 'src/tools/wasm-ctor-eval.cpp')
-rw-r--r--src/tools/wasm-ctor-eval.cpp5
1 files changed, 5 insertions, 0 deletions
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 {