Fix memory/table segment checks in memory.init/table.init #3081
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to the wasm core spec, the checks for the table segments in
table.init
opcode are similar to the checks formemory.init
opcode:data.drop
(or
elem.drop
) opcode is executed, but it can be used to domemory.init
(ortable.init
) againmemory.init
only traps whens+n > len(data.data)
ord+n > len(mem.data)
and
table.init
only traps whens+n > len(elem.elem)
ord+n > len(tab.elem)
memory.init
(ortable.init
), while it behaves like a dropped passive segementhttps://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
ps.
https://webassembly.github.io/spec/core/bikeshed/#-hrefsyntax-instr-memorymathsfmemoryinitx%E2%91%A0
https://webassembly.github.io/spec/core/bikeshed/#-hrefsyntax-instr-tablemathsftableinitxy%E2%91%A0
#3020