-
Notifications
You must be signed in to change notification settings - Fork 40
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
Contracts & Harnesses for unchecked_add
#91
Contracts & Harnesses for unchecked_add
#91
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's awesome! Thanks
Have you tried using a macro for generating the harness? I think it will be cleaner, but not a requirement.
I haven't tried with |
Sorry, my bad. I meant just regular macros |
Do you mean "declarative macros"? How could it be used? I guess the macro can take the method to verify and the input type (e.g. i8, i16). I'm not familiar with it. I'll research it more. |
unchecked_add
unchecked_add
* Added harnesses for unchecked multiplication (`unchecked_mul`) and shift right (`unchecked_shr`) * Added a macro and input limits for multiplication proofs * Reduced duplicity in code by using macros to generate proof harnesses
unchecked_add
unchecked_add
, unchecked_mul
, unchecked_shr
unchecked_add
, unchecked_mul
, unchecked_shr
unchecked_add
@feliperodri @celinval Hello! The previous build failed due to an unused import. I fixed that and all looks good now. Could you approve the workflow? Once it passes the checks, we'll get this PR merged. Thank you :) |
Hi @Yenyun035, I am the member of AWS team 4, after our team merge the main branch with this commit, there is a compiling error happens, like:
I was wondering if this changes using some custom version of Kani? |
We tried using the
This compilation error prevents us from running any individual harnesses in the library. |
@QinyuanWu @danielhumanmod Hi. Regarding your question about kani, yes. In our case, we need to manually build kani from source (
|
…ed_shl` and `unchecked_shr` (#96) Towards : issue #59 Parent branch : [c-0011-core-nums-yenyunw-unsafe-ints](https://github.com/rajathkotyal/verify-rust-std/tree/c-0011-core-nums-yenyunw-unsafe-ints ) - Tracking PR #91 --------- Co-authored-by: yew005 <yew005@ucsd.edu> Co-authored-by: MWDZ <jinjunfeng721@gmail.com> Co-authored-by: Lanfei Ma <99311320+lanfeima@users.noreply.github.com> Co-authored-by: Yenyun035 <yenyunw@andrew.cmu.edu>
Towards #53 ## Changes Three function contracts & four harnesses: - added contract and harness for `non_null::add` - added contract and harness for `non_null::addr` - added contract and harnesses for `non_null::align_offset`, including both positive and negative harness that triggers panic. The ensures clause for `align_offset` is referenced from [`align_offset`](https://github.com/model-checking/verify-rust-std/pull/69/files) in `library/core/src/ptr/mod.rs`. ## Revalidation To revalidate the verification results, run `kani verify-std -Z unstable-options "path/to/library" -Z function-contracts -Z mem-predicates --harness ptr::non_null::verify`. This will run all six harnesses in the module. All default checks should pass: ``` SUMMARY: ** 0 of 1556 failed VERIFICATION:- SUCCESSFUL Verification Time: 0.28004378s Complete - 6 successfully verified harnesses, 0 failures, 6 total. ``` ### :exclamation: Warning Running the above command with the default installed cargo kani will result in compilation error due to the latest merged from [PR#91](#91). Detailed errors are commented under that PR. This issue is waiting to be resolved. ## TODO: - Use `Layout` to create dynamically sized arrays in place of fixed size array in harnesses. This approach currently has errors and is documented in [discussion](#104). - Verify multiple data types: these will be added in future PR. - Add `requires` clause in contract to constrain `count` to be within object memory size: there is a current [issue](#99) with using `ub_checks::can_write` to get the object size. A workaround is implemented in the harness. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Carolyn Zech <cmzech@amazon.com>
Resolves #59
Changes
unchecked_add
(located inlibrary/core/src/num/int_macros.rs
anduint_macros.rs
)unchecked_add
of each integer typei8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
,usize
--- 12 harnesses in total.Revalidation
feature/verify-rust-std
branch.<harness_to_run>
can be eithernum::verify
to run all harnesses ornum::verify::<harness_name>
(e.g.check_unchecked_add_i8
) to run a specific harness.Except
isize
andusize
harnesses passing 1203 checks, all harnesses should pass the same 1229 checks (1200 checks on 09/24/2024):By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.