Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[19.0.0] Fix a panic using tables with the wrong type #8284

Merged
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
7 changes: 6 additions & 1 deletion crates/runtime/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,12 @@ impl Instance {
// disconnected from the lifetime of `self`.
let module = self.module().clone();

let empty = TableSegmentElements::Functions(Box::new([]));
// NB: fall back to an expressions-based list of elements which doesn't
// have static type information (as opposed to `Functions`) since we
// don't know just yet what type the table has. The type will be be
// inferred in the next step within `table_init_segment`.
let empty = TableSegmentElements::Expressions(Box::new([]));

let elements = match module.passive_elements_map.get(&elem_index) {
Some(index) if !self.dropped_elements.contains(elem_index) => {
&module.passive_elements[*index]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
(module
(table $t 0 0 externref)

(func (export "f1")
(i32.const 0)
(i32.const 0)
(i32.const 0)
(table.init $t $declared)
)

(func (export "f2")
(i32.const 0)
(i32.const 0)
(i32.const 0)
(table.init $t $passive)

(elem.drop $passive)

(i32.const 0)
(i32.const 0)
(i32.const 0)
(table.init $t $passive)
)

(func (export "f3")
(i32.const 0)
(i32.const 0)
(i32.const 0)
(table.init $t $active)
)

(elem $declared declare externref)
(elem $passive externref)
(elem $active (i32.const 0) externref)
)

(assert_return (invoke "f1"))
(assert_return (invoke "f2"))
(assert_return (invoke "f3"))
Loading