Skip to content

Commit

Permalink
[interpreter] Fix crashes on try_table with parameters (#321)
Browse files Browse the repository at this point in the history
The test case was ported from toywasm.
  • Loading branch information
yamt authored Jul 4, 2024
1 parent cfb909d commit 5837755
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion interpreter/exec/eval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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', []
Expand Down
6 changes: 6 additions & 0 deletions test/core/try_table.wast
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5837755

Please sign in to comment.