Fix var_u{32,64} parsing in memories and tables
#2178
Closed
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.
I tried to update Wasmi to
wasmparser v0.229and encountered the following bug in the existing Wasm spec testsuite:tl;dr:
integer representation too longAfter some debugging I found that this PR recently changed the logic to parse
var_u32orvar_u64depending onmemory64flags formemories.rsand fortables.rs.It looked strange to me since
memory64andtable64flags are first extracted from someflagsbitfields and then the new PR usesreader.memory64()andreader.table64()instead for querying those features.Before the mentioned PR, it uses
read_var_u64only for memories and tables which explicitly are flagged asmemory64whereas now, it uses the reader'smemory64proposal flag instead. To me this looks incorrect.With this PR I successfully fixed the bugs I found on Wasmi by simply reverting the logic to before the mentioned PR.
However, the Wasm spec testsuite of
wasm-toolsis unhappy now.edit: Hmm, I just noticed that the Wasm 3.0 spec demands to always parse
limitsasu64values, so indeed the current behavior ofwasmparsermight be correct.@alexcrichton @keithw