Skip to content

Fix Memory64Lowering table.copy size wrapping for mixed tables#8319

Merged
kripken merged 1 commit intoWebAssembly:mainfrom
sumleo:fix-memory64-table-copy
Feb 13, 2026
Merged

Fix Memory64Lowering table.copy size wrapping for mixed tables#8319
kripken merged 1 commit intoWebAssembly:mainfrom
sumleo:fix-memory64-table-copy

Conversation

@sumleo
Copy link
Contributor

@sumleo sumleo commented Feb 12, 2026

Summary

visitTableCopy wrapped curr->size using only the dest table's type, but the wasm spec (and child-typer.h) defines the size type as i64 only when both source and dest tables are 64-bit. When copying between a 64-bit and a 32-bit table, the size is i32, but wrapping checks only the dest table — causing an assertion failure (assert(ptr->type == Type::i64)) when dest is 64-bit but source is 32-bit.

Fix: Check both tables before wrapping the size operand, matching the type logic in child-typer.h.

Split from #8311 per review feedback.

Test plan

  • New lit test memory64-lowering-table-copy.wast covering:
    • Copy from 64-bit to 32-bit table (size stays i32, no crash)
    • Copy from 32-bit to 64-bit table (size stays i32, no crash)
    • Copy between two 64-bit tables (all operands including size are wrapped)
  • All 309 unit tests pass

visitTableCopy wrapped curr->size using only the dest table's
type, but the size operand is i64 only when both source and dest
tables are 64-bit. When copying between tables of different address
types, wrapping an i32 size as if it were i64 causes an assertion
failure.

Check both tables before wrapping the size operand, matching the
type logic in child-typer.h.
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Thanks!

@kripken kripken merged commit 204c3f8 into WebAssembly:main Feb 13, 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.

2 participants