forked from model-checking/kani
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Regression for delayed UB for slices: rust-lang/rust#135265
- Loading branch information
1 parent
bf7f55b
commit 09e2283
Showing
5 changed files
with
28 additions
and
20 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
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 @@ | ||
delayed_ub_slices.assertion.\ | ||
- Status: FAILURE\ | ||
- Description: "Undefined Behavior: Reading from an uninitialized pointer of type `[u128; 4]`" | ||
|
||
Verification failed for - delayed_ub_slices |
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,21 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-flags: -Z ghost-state -Z uninit-checks | ||
|
||
//! Checks that Kani catches instances of delayed UB for slices. | ||
//! This test used to live inside delayed-ub, but the 2/5/2025 toolchain upgrade introduced a regression for this test. | ||
//! Once this test is fixed, move it back into delayed-ub.rs | ||
//! See https://github.com/model-checking/kani/issues/3881 for details. | ||
/// Delayed UB via mutable pointer write into a slice element. | ||
#[kani::proof] | ||
fn delayed_ub_slices() { | ||
unsafe { | ||
// Create an array. | ||
let mut arr = [0u128; 4]; | ||
// Get a pointer to a part of the array. | ||
let ptr = &mut arr[0..2][0..1][0] as *mut _ as *mut (u8, u32); | ||
*ptr = (4, 4); | ||
let arr_copy = arr; // UB: This reads a padding value inside the array! | ||
} | ||
} |