fix: ins ror_val out of range#477
Merged
eigmax merged 5 commits intopre-release-v1.2.5from Mar 17, 2026
Merged
Conversation
blake-pro
approved these changes
Mar 16, 2026
felicityin
approved these changes
Mar 17, 2026
VanhGer
approved these changes
Mar 17, 2026
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.
The INS instruction shifted ror_val right by msb - lsb + 1. When
msb=31, lsb=0, the shift amount is 32, exceeding the ShiftRight chip's [0,
31] range limit.
Fix 1: Split INS SRL into two steps (across multiple files)
Problem: The INS instruction shifted ror_val right by msb - lsb + 1. When
msb=31, lsb=0, the shift amount is 32, exceeding the ShiftRight chip's [0,
31] range limit.
Fix: Split the single >> (msb - lsb + 1) into two steps:
Fix 2: add.rs:43-44 debug_assert correction (just now)
Problem: The debug_assert for byte 3 overflow omitted carry[2]:
// Old: missing carry[2]
let overflow = a[3].wrapping_add(b[3]).wrapping_sub(expected[3]) as u32;
When byte 2 produces a carry (carry[2]=1) but byte 3 doesn't overflow,
overflow evaluates to 255 instead of 0, triggering the assertion.
Fix: Use correct u32 arithmetic including carry[2]:
// New: correct
let overflow = (a[3] as u32) + (b[3] as u32) + (carry[2] as u32) -
(expected[3] as u32);
debug_assert!(overflow == 0 || overflow == 256);
The AIR constraint in eval() (line 73: overflow_3 = a[3] + b[3] - value[3] +
carry[2]) was always correct. Only the debug_assert in populate had the
latent bug, which was exposed by the new intermediate values from Fix 1.