Skip to content

Commit

Permalink
Add test case from issue #3061
Browse files Browse the repository at this point in the history
  • Loading branch information
karkhaz committed Mar 12, 2024
1 parent b318ed5 commit d77ac68
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/expected/dead-invalid-access-via-raw/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SUCCESS\
address must be a multiple of its type's alignment
FAILURE\
unsafe { *raw_ptr } == 10
SUCCESS\
pointer NULL
SUCCESS\
pointer invalid
SUCCESS\
deallocated dynamic object
FAILURE\
dead object
SUCCESS\
pointer outside object bounds
SUCCESS\
invalid integer address
12 changes: 12 additions & 0 deletions tests/expected/dead-invalid-access-via-raw/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

#[kani::proof]
pub fn check_invalid_ptr() {
let raw_ptr = {
let var = 10;
&var as *const _
};
// This should fail since it is de-referencing a dead object.
assert_eq!(unsafe { *raw_ptr }, 10);
}

0 comments on commit d77ac68

Please sign in to comment.