-
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.
Deprecate kani::slice::any_slice in Kani 0.38.0 (and the related AnySlice struct), and remove it in a later version. Motivation: The Kani library's `slice::any_slice` API is doing more harm than benefit: it is meant to provide a convenient way for users to generate non-deterministic slices, but its current implementation aims to avoid any unsoundness by making sure that for the non-deterministic slice returned by the API, accessing memory beyond the slice length is flagged as an out-of-bounds access (see #1009 for details). However, in practical scenarios, using it ends up causing memory to blowup for CBMC. Given that users may not care about this type of unsoundness, which is only possible through using a pointer dereference inside an unsafe block (see discussion in #2634). Thus, we should leave it to the user to decide the suitable method for generating slices that fits their verification needs. For example, they can use Kani's alternative API, `any_slice_of_array` that extracts a slice of a non-deterministic start and end from a given array.
- Loading branch information
1 parent
6b1a09d
commit 8480dc6
Showing
11 changed files
with
62 additions
and
66 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
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,5 +1,14 @@ | ||
Failed Checks: assertion failed: s.len() != 0 | ||
Failed Checks: assertion failed: s.len() != 1 | ||
Failed Checks: assertion failed: s.len() != 2 | ||
Failed Checks: assertion failed: s.len() != 3 | ||
Failed Checks: assertion failed: s.len() != 4 | ||
Status: SATISFIED\ | ||
Description: "cover condition: s.len() == 0" | ||
|
||
Status: SATISFIED\ | ||
Description: "cover condition: s.len() == 1" | ||
|
||
Status: SATISFIED\ | ||
Description: "cover condition: s.len() == 2" | ||
|
||
Status: SATISFIED\ | ||
Description: "cover condition: s.len() == 3" | ||
|
||
Status: SATISFIED\ | ||
Description: "cover condition: s.len() == 4" |
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,15 +1,16 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// This test checks that non-det slices created using kani::slice::any_slice can | ||
// This test checks that non-det slices created using `kani::slice::any_slice_of_array` | ||
// assume any length up the specified maximum | ||
|
||
#[kani::proof] | ||
fn check_possible_slice_lengths() { | ||
let s = kani::slice::any_slice::<i32, 4>(); | ||
assert!(s.len() != 0); | ||
assert!(s.len() != 1); | ||
assert!(s.len() != 2); | ||
assert!(s.len() != 3); | ||
assert!(s.len() != 4); | ||
let arr: [i32; 4] = kani::any(); | ||
let s = kani::slice::any_slice_of_array(&arr); | ||
kani::cover!(s.len() == 0); | ||
kani::cover!(s.len() == 1); | ||
kani::cover!(s.len() == 2); | ||
kani::cover!(s.len() == 3); | ||
kani::cover!(s.len() == 4); | ||
} |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
warning: use of deprecated function `kani::slice::any_slice`: Use `any_slice_of_array` or `any_slice_of_array_mut` instead | ||
warning: use of deprecated struct `kani::slice::AnySlice`: Use `any_slice_of_array` or `any_slice_of_array_mut` instead |
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,10 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
//! A test that checks that Kani emits the deprecated message for `any_slice` | ||
//! and `AnySlice` | ||
|
||
#[kani::proof] | ||
fn check_any_slice_deprecated() { | ||
let _s: kani::slice::AnySlice<i32, 5> = kani::slice::any_slice(); | ||
} |