Skip to content
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

Use box in shadow memory test for reliable object count #3380

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/expected/shadow/unsupported_num_objects/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ fn check_max_objects<const N: usize>() {
// - the NULL pointer whose object ID is 0, and
// - the object ID for `i`
while i < N {
let x = i;
assert_eq!(kani::mem::pointer_object(&x as *const usize), i + 2);
let x: Box<usize> = Box::new(i);
assert_eq!(kani::mem::pointer_object(&*x as *const usize), 2 * i + 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for the multiplication by 2? Is there an object for the box and another for the variable x? If so, would inlining the Box:new operation in the assert remove the doubling?

i += 1;
}

// create a new object whose ID is `N` + 2
let x = 42;
assert_eq!(kani::mem::pointer_object(&x as *const i32), N + 2);
assert_eq!(kani::mem::pointer_object(&x as *const i32), 2 * N + 2);
// the following call to `set` would fail if the object ID for `x` exceeds
// the maximum allowed by Kani's shadow memory model
unsafe {
Expand All @@ -32,10 +32,10 @@ fn check_max_objects<const N: usize>() {

#[kani::proof]
fn check_max_objects_pass() {
check_max_objects::<1021>();
check_max_objects::<510>();
}

#[kani::proof]
fn check_max_objects_fail() {
check_max_objects::<1022>();
check_max_objects::<511>();
}
Loading