You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Contracts & Harnesses for add, addr, and align_offset (#105)
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 <[email protected]>
0 commit comments