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.
- Loading branch information
1 parent
e1dd44a
commit 4781127
Showing
6 changed files
with
48 additions
and
11 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
check_misaligned_ptr_cast_fail.safety_check\ | ||
Status: FAILURE\ | ||
Description: "misaligned pointer to reference cast: address must be a multiple of its type's alignment"\ | ||
in function check_misaligned_ptr_cast_fail |
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,20 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
//! This test checks that Kani detects UB resulting from converting a raw | ||
//! pointer to a reference when the pointer is not properly aligned. | ||
|
||
#[repr(align(4))] | ||
#[derive(Clone, Copy)] | ||
struct AlignedI32(i32); | ||
|
||
#[kani::proof] | ||
fn check_misaligned_ptr_cast_fail() { | ||
let data = AlignedI32(42); | ||
let ptr = &data as *const AlignedI32; | ||
|
||
unsafe { | ||
let misaligned = ptr.byte_add(1); | ||
let x = unsafe { &*misaligned }; | ||
} | ||
} |
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,6 +1,6 @@ | ||
Status: FAILURE\ | ||
Description: "dereference failure: pointer invalid"\ | ||
|
||
Verification failed for - check_with_byte_add | ||
Verification failed for - check_with_metadata | ||
Verification failed for - check_with_byte_add_fail | ||
Verification failed for - check_with_metadata_fail | ||
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