Conversation
bitsetBitfieldComparison guards the shift with testShiftInRange's 0..63 check (64-bit word semantics) but shifts 1usize. On 32-bit targets (wasm32), usize is 32 bits and the shift amount wraps mod 32, so e.g. 1usize << 35 evaluates to 1 << 3 -- false set-membership, and ATN prediction takes the wrong alternative for any token whose offset lands in 32..63. Widening the literal to u64 matches the guard's assumption and is semantically identical on 64-bit targets. Fixes #47
Scans tests/gen for '1usize <<' -- enforceable on 64-bit CI (where the behavioral bug is invisible) because build.rs regenerates tests/gen from the grammars whenever the tool jar is present, so a template regression trips this on the next generating run. Also widens the one occurrence in the checked-in csvparser.rs, which was produced by the unfixed template. Full behavioral repro requires a 32-bit target (e.g. cargo test --target wasm32-wasip1); documented in the test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #47.
bitsetBitfieldComparisonguards the shift withtestShiftInRange's 0..63 check (64-bit word semantics) but shifts1usize. On 32-bit targets (wasm32),usizeis 32 bits and the shift amount wraps mod 32, so e.g.1usize << 35evaluates to1 << 3— false set-membership, and ATN prediction takes the wrong alternative for any token whose offset lands in 32..63 of a decision's mask. Same input parses correctly on 64-bit targets, which is what makes this easy to miss.Widening the literal to
u64matches the guard's assumption and is semantically identical on 64-bit (the mask literal infersu64from the lhs). Verified downstream on a large community grammar: applying exactly this widening to the generated output fixed all wasm32 misparses with no behavior change on 64-bit.