From 583775527f151276b60876aab99162da14226283 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 4 Jul 2024 16:24:35 +0900 Subject: [PATCH] [interpreter] Fix crashes on try_table with parameters (#321) The test case was ported from toywasm. --- interpreter/exec/eval.ml | 2 +- test/core/try_table.wast | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/interpreter/exec/eval.ml b/interpreter/exec/eval.ml index 13f82a9d..17baad84 100644 --- a/interpreter/exec/eval.ml +++ b/interpreter/exec/eval.ml @@ -244,7 +244,7 @@ let rec step (c : config) : config = let n1 = Lib.List32.length ts1 in let n2 = Lib.List32.length ts2 in let args, vs' = take n1 vs e.at, drop n1 vs e.at in - vs', [Handler (n2, cs, (args, [Label (n2, [], ([], List.map plain es')) @@ e.at])) @@ e.at] + vs', [Handler (n2, cs, ([], [Label (n2, [], (args, List.map plain es')) @@ e.at])) @@ e.at] | Drop, v :: vs' -> vs', [] diff --git a/test/core/try_table.wast b/test/core/try_table.wast index e64b6c18..43ae52cc 100644 --- a/test/core/try_table.wast +++ b/test/core/try_table.wast @@ -238,6 +238,10 @@ ) ) ) + + (func (export "try-with-param") + (i32.const 0) (try_table (param i32) (drop)) + ) ) (assert_return (invoke "simple-throw-catch" (i32.const 0)) (i32.const 23)) @@ -294,6 +298,8 @@ (assert_exception (invoke "return-call-in-try-catch")) (assert_exception (invoke "return-call-indirect-in-try-catch")) +(assert_return (invoke "try-with-param")) + (module (func $imported-throw (import "test" "throw")) (tag $e0)