-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove assigns clause for ZST pointers (#3417)
This PR filters out ZST pointee types when generating CMBC assigns clauses for contracts. This prevents CMBC from complaining that the pointer doesn't point to a valid allocation. Resolves #3181 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
- Loading branch information
1 parent
b24c01b
commit 5424bc5
Showing
7 changed files
with
37 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.assertion\ | ||
- Status: SUCCESS\ | ||
- Description: "ptr NULL or writable up to size"\ | ||
|
||
VERIFICATION:- SUCCESSFUL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-flags: -Zfunction-contracts | ||
|
||
#[kani::modifies(dst)] | ||
pub unsafe fn replace<T>(dst: *mut T, src: T) -> T { | ||
std::ptr::replace(dst, src) | ||
} | ||
|
||
#[kani::proof_for_contract(replace)] | ||
pub fn check_replace_unit() { | ||
check_replace_impl::<()>(); | ||
} | ||
|
||
fn check_replace_impl<T: kani::Arbitrary + Eq + Clone>() { | ||
let mut dst = T::any(); | ||
let orig = dst.clone(); | ||
let src = T::any(); | ||
let ret = unsafe { replace(&mut dst, src.clone()) }; | ||
assert_eq!(ret, orig); | ||
assert_eq!(dst, src); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
Checking harness mem::verify::check_swap_unit... | ||
|
||
Failed Checks: ptr NULL or writable up to size | ||
|
||
Summary: | ||
Verification failed for - mem::verify::check_swap_unit | ||
Complete - 6 successfully verified harnesses, 1 failures, 7 total. | ||
Complete - 7 successfully verified harnesses, 0 failures, 7 total. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
Summary: | ||
Verification failed for - ptr::verify::check_replace_unit | ||
Verification failed for - ptr::verify::check_as_ref_dangling | ||
Complete - 4 successfully verified harnesses, 2 failures, 6 total. | ||
Complete - 5 successfully verified harnesses, 1 failures, 6 total. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters