Skip to content

Validator: thread table limits through OnReturnCallIndirect#2744

Merged
sbc100 merged 1 commit into
WebAssembly:mainfrom
ggreif:gabor/return-call-indirect-table64
May 6, 2026
Merged

Validator: thread table limits through OnReturnCallIndirect#2744
sbc100 merged 1 commit into
WebAssembly:mainfrom
ggreif:gabor/return-call-indirect-table64

Conversation

@ggreif
Copy link
Copy Markdown
Contributor

@ggreif ggreif commented May 6, 2026

SharedValidator::OnCallIndirect passes table_type.limits to TypeChecker::OnCallIndirect, which expects i64 vs i32 for the table-index based on is_64. OnReturnCallIndirect doesn't — so under table64, plain call_indirect with an i64 index validates, but the matching return_call_indirect rejects it with expected [i32] but got [i64].

Mirrors the signature. Adds a test/typecheck/ regression for the negative case.

`SharedValidator::OnCallIndirect` passes `table_type.limits` to
`TypeChecker::OnCallIndirect`, which uses `is_64` to expect i64 vs i32
for the table-index operand. `OnReturnCallIndirect` doesn't, so under
table64 plain `call_indirect` with an i64 index validates while the
matching `return_call_indirect` rejects it with `expected [i32] but
got [i64]`. Fix: mirror the signature.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ggreif ggreif force-pushed the gabor/return-call-indirect-table64 branch from 7d5da6c to f7d23a8 Compare May 6, 2026 12:28
@ggreif ggreif changed the title Validator: thread table limits through OnReturnCallIndirect Validator: thread table limits through OnReturnCallIndirect May 6, 2026
ggreif added a commit to caffeinelabs/motoko that referenced this pull request May 6, 2026
`return_call_indirect` under `table64` rejects an i64 table-index in
upstream wabt, while the matching `call_indirect` accepts it — a
clean asymmetry in the validator. The patched wabt mirrors the
working `OnCallIndirect` plumbing in `OnReturnCallIndirect` (4 lines
+ a regression test). With the patch, our `tailcall` bench's
`return_call_indirect` sites validate clean and the temporary
`tailcall.valid.{ok,ret.ok}` files this PR introduced are no longer
needed — drop them.

Patch is fetched from the open upstream PR via `fetchpatch`. Drop
this overlay (and the two-line `__intentionallyOverridingVersion`
shim) once the fix lands and nixpkgs picks it up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sbc100
Copy link
Copy Markdown
Member

sbc100 commented May 6, 2026

Thanks!

@sbc100 sbc100 merged commit 282e2e5 into WebAssembly:main May 6, 2026
17 checks passed
@ggreif
Copy link
Copy Markdown
Contributor Author

ggreif commented May 6, 2026

@sbc100 thanks for reviewing and merging! What is the schedule for 1.0.41? Any plans? It would be cool to have a release before the nixpkgs (26.05, stable) happens...

@ggreif ggreif deleted the gabor/return-call-indirect-table64 branch May 6, 2026 15:09
@sbc100
Copy link
Copy Markdown
Member

sbc100 commented May 6, 2026

I can do a release today

@ggreif ggreif mentioned this pull request May 7, 2026
3 tasks
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.

2 participants