Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit for unchecked intrinsics #1076

Merged
merged 6 commits into from
Apr 20, 2022

Conversation

adpaco-aws
Copy link
Contributor

@adpaco-aws adpaco-aws commented Apr 20, 2022

Description of changes:

Reviews and adds tests for all unchecked_* operations.

The most notable change is the addition of an overflow check for unchecked_div and unchecked_rem, which were not failing in the case where a == T::MIN && b == -1. This check was already written for exact_div so I refactored it into a function which is now used for unchecked div/rem.

Then, I was afraid this was also the case for standard div/rem operations, but turns out this overflow check is already covered so no changes are needed. The tests I wrote to verify this are included as well.

Resolved issues:

Part of #727

Call-outs:

Testing:

  • How is this change tested? Adds many tests, in particular the ones to check an overflow that was previously not checked.

  • Is this a refactor change? No.

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@adpaco-aws adpaco-aws requested a review from a team as a code owner April 20, 2022 15:03
@adpaco-aws adpaco-aws changed the title Unchecked audit Audit for unchecked intrinsics Apr 20, 2022
@adpaco-aws adpaco-aws merged commit 4019f0c into model-checking:main Apr 20, 2022
@adpaco-aws adpaco-aws mentioned this pull request Apr 20, 2022
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 22, 2022
* Add positive test cases

* Refactor `div_does_not_overflow` into fn, use in macro

* Add negative test cases

* Add negative tests for regular div/rem

* Minor fixes for div/rem cases
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 25, 2022
* Add positive test cases

* Refactor `div_does_not_overflow` into fn, use in macro

* Add negative test cases

* Add negative tests for regular div/rem

* Minor fixes for div/rem cases
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 26, 2022
* Add positive test cases

* Refactor `div_does_not_overflow` into fn, use in macro

* Add negative test cases

* Add negative tests for regular div/rem

* Minor fixes for div/rem cases
tedinski pushed a commit that referenced this pull request Apr 27, 2022
* Add positive test cases

* Refactor `div_does_not_overflow` into fn, use in macro

* Add negative test cases

* Add negative tests for regular div/rem

* Minor fixes for div/rem cases
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.

2 participants