-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove isize overflow check for zst offsets
- Loading branch information
1 parent
ff3aea3
commit 05e0599
Showing
7 changed files
with
77 additions
and
45 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
6 changes: 4 additions & 2 deletions
6
tests/expected/offset-bounds-check/out_of_bounds_ub_check.expected
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,6 @@ | ||
Failed Checks: Offset result and original pointer must point to the same allocation | ||
Verification failed for - check_ptr_oob | ||
Failed Checks: Offset result and original pointer must point to the same allocation | ||
|
||
Complete - 1 successfully verified harnesses, 1 failures, 2 total. | ||
Verification failed for - test_offset_overflow | ||
Verification failed for - check_ptr_oob | ||
Complete - 1 successfully verified harnesses, 2 failures, 3 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 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,8 @@ | ||
<usize as kani::rustc_intrinsics::ToISize>::to_isize.safety_check\ | ||
- Status: FAILURE\ | ||
- Description: "Offset value overflows isize" | ||
|
||
Failed Checks: Offset value overflows isize | ||
|
||
Verification failed for - test_non_zst | ||
Complete - 1 successfully verified harnesses, 1 failures, 2 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// Checks that `offset` does not accept a `count` greater than isize::MAX, | ||
// except for ZSTs | ||
|
||
#![feature(core_intrinsics)] | ||
use std::intrinsics::offset; | ||
|
||
#[kani::proof] | ||
fn test_zst() { | ||
let mut x = (); | ||
let ptr: *mut () = &mut x as *mut (); | ||
let count: usize = (isize::MAX as usize) + 1; | ||
let _ = unsafe { ptr.add(count) }; | ||
} | ||
|
||
#[kani::proof] | ||
fn test_non_zst() { | ||
let mut x = 7; | ||
let ptr: *mut i32 = &mut x as *mut i32; | ||
let count: usize = (isize::MAX as usize) + 1; | ||
let _ = unsafe { ptr.add(count) }; | ||
} |