Skip to content

[validator] Allow call_indirect/return_call_indirect table elements to be subtypes of funcref - #2780

Merged
sbc100 merged 4 commits into
WebAssembly:mainfrom
6d6f6d656e746f:fix-call-indirect-table-validation
Jul 3, 2026
Merged

sbc100 merged 4 commits into
WebAssembly:mainfrom
6d6f6d656e746f:fix-call-indirect-table-validation

Conversation

@6d6f6d656e746f

@6d6f6d656e746f 6d6f6d656e746f commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

This PR resolves an issue where the validator rejects valid WebAssembly modules using typed function references (such as (ref null $sig)) with call_indirect and return_call_indirect.
Currently, SharedValidator performs a strict equality check (table_type.element != Type::FuncRef), which rejects valid subtypes of funcref in indirect calls.
Changes:

  • Replaced the strict equality check in src/shared-validator.cc with typechecker_.CheckType to correctly check for subtypes of funcref.
  • Handled out-of-range table index checks to maintain compatibility with existing spec test outputs.

Fixes: #2523

Use subtype checking in SharedValidator to allow tables containing typed function references as table elements, satisfying the Wasm GC / Typed Function References spec.
@zherczeg

Copy link
Copy Markdown
Collaborator

The referenced issue used (table 2 externref), which was invalid for call_indirect. Isn't this patch is the opposite of it? GC patches probably affect this problem.

@6d6f6d656e746f

Copy link
Copy Markdown
Contributor Author

Thanks for the reply,
The current check (table_type.element != Type::FuncRef) rejects valid tables containing typed function references that are subtypes of funcref like (ref null $sig).

This patch replaces it with a subtype check, which still rejects externref because its not a subtype of funcref and now correctly allows typed function reference tables.

Please let me know if I'm missing something

@zherczeg

Copy link
Copy Markdown
Collaborator

Tests should be added to show which matches / don't match to the new check.

@zherczeg zherczeg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sbc100
sbc100 merged commit e62f23c into WebAssembly:main Jul 3, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing Table Type Validation in call_indirect Instruction

3 participants