-
Notifications
You must be signed in to change notification settings - Fork 41
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
Contract and harness for as_ptr, cast, as_mut_ptr, and as_non_null_ptr #126
Conversation
@zhassan-aws , I have made the required changes based on your feedback. Kindly review it again. |
f151222
to
9bd3888
Compare
I made the changes and the contracts were successful. ` VERIFICATION:- SUCCESSFUL Complete - 4 successfully verified harnesses, 0 failures, 4 total.` |
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.
Thanks
Co-authored-by: Zyad Hassan <[email protected]>
Co-authored-by: Zyad Hassan <[email protected]>
Co-authored-by: Zyad Hassan <[email protected]>
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.
Please resolve the conflicts, and I'll go ahead and merge.
@zhassan-aws , I have resolved the conflicts. Thanks for helping revert the submodule! |
trigger approval workflow |
@Dhvani-Kapadia Can you please review the CI failures? |
@Dhvani-Kapadia @zhassan-aws @celinval The two compiler errors are
After looking into the code it seems like the error is in the implementation of the function: //nonnull.rs
#[ensures(|result: &*mut T| *result == self.pointer as *mut T)]
pub const fn as_mut_ptr(self) -> *mut T {
self.as_non_null_ptr().as_ptr() // line 1483
}
//c_str.rs
#[inline]
#[must_use]
const fn as_non_null_ptr(&self) -> NonNull<c_char> {
// FIXME(const_trait_impl) replace with `NonNull::from`
// SAFETY: a reference is never null
unsafe { NonNull::new_unchecked(&self.inner as *const [c_char] as *mut [c_char]) } //line 536
.as_non_null_ptr()
} This is using kani commit |
Hey @zhassan-aws , could you please merge it |
Description
This PR includes contracts and proof harnesses for the four APIs as_ptr, cast, as_mut_ptr, and as_non_null_ptr which are part of the NonNull library in Rust.
Changes Overview:
Covered APIs:
NonNull::as_ptr: Acquires the underlying *mut pointer
NonNull::cast: Casts to a pointer of another type
NonNull:: as_mut_ptr: Returns raw pointer to array's buffer
NonNull::as_non_null_ptr: Returns a non-null pointer to slice's buffer
Proof harness:
non_null_check_as_ptr
non_null_check_cast
non_null_check_as_mut_ptr
non_null_check_as_non_null_ptr
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 four harnesses in the module. All default checks should pass:
Towards issue #53
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.