Skip to content

Fix optimization specific SREM edge case#527

Merged
xermicus merged 10 commits into
mainfrom
cl/srem
May 28, 2026
Merged

Fix optimization specific SREM edge case#527
xermicus merged 10 commits into
mainfrom
cl/srem

Conversation

@xermicus
Copy link
Copy Markdown
Member

@xermicus xermicus commented May 26, 2026

Existing test coverage didn't catch a signed remainder overflow semantics edge case behavior where at least one the operators is being constant folded by LLVM instead of solc. This PR fixes the SREM translation bug and adds missing test coverage for division ops with constants.

Closes #524

xermicus added 3 commits May 26, 2026 12:59
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
@xermicus xermicus requested review from elle-j and kvpanch May 26, 2026 12:00
Copy link
Copy Markdown
Contributor

@kvpanch kvpanch left a comment

Choose a reason for hiding this comment

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

maybe we need to add fuzzer similar to PVM ?

@xermicus
Copy link
Copy Markdown
Member Author

maybe we need to add fuzzer similar to PVM ?

Yes we do. Its on the back of my mind since a long while. This is also the reason why I the LLVM builder supports building with coverage.

@xermicus xermicus changed the title Fix optimzation specific SREM edge case Fix optimization specific SREM edge case May 26, 2026
Copy link
Copy Markdown
Contributor

@elle-j elle-j left a comment

Choose a reason for hiding this comment

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

LGTM, could you add a CHANGELOG entry briefly describing this fix?


/// Surfaces the `smod(INT_MIN, -1)` LLVM-UB const-fold bug from
/// paritytech/revive#524. See `SmodIntMinNegOneBug.yul` for why this specific
/// fixture is shaped the way it is. Expected to FAIL until the bug is fixed.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// fixture is shaped the way it is. Expected to FAIL until the bug is fixed.
/// fixture is shaped the way it is.

xermicus added 7 commits May 26, 2026 17:06
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
@xermicus xermicus merged commit 40e97d1 into main May 28, 2026
47 of 54 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.

Miscompile in __revive_signed_remainder: srem(INT256_MIN, -1) UB

3 participants