Skip to content

Commit

Permalink
-Z uninit-checks automatically enables shadow memory
Browse files Browse the repository at this point in the history
  • Loading branch information
artemagvanian committed Jul 8, 2024
1 parent 898dd0b commit b388458
Show file tree
Hide file tree
Showing 19 changed files with 22 additions and 19 deletions.
5 changes: 4 additions & 1 deletion kani-driver/src/call_single_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ impl KaniSession {
}

if self.args.common_args.unstable_features.contains(UnstableFeature::UninitChecks) {
flags.push("--ub-check=uninit".into())
// Automatically enable shadow memory, since the version of uninitialized memory checks
// without non-determinism depends on it.
flags.push("-Z ghost-state".into());
flags.push("--ub-check=uninit".into());
}

if self.args.ignore_locals_lifetime {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::ptr::addr_of;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::ptr;
#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expected/uninit/alloc-to-slice/alloc-to-slice.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::alloc::{alloc, Layout};
use std::slice::from_raw_parts;
Expand Down
2 changes: 1 addition & 1 deletion tests/expected/uninit/atomic/atomic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

#![feature(core_intrinsics)]

Expand Down
2 changes: 1 addition & 1 deletion tests/expected/uninit/intrinsics/intrinsics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks
//! Checks that Kani supports memory initialization checks via intrinsics.

#![feature(core_intrinsics)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expected/uninit/vec-read-bad-len/vec-read-bad-len.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::ops::Index;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

/// Checks that Kani catches an attempt to read uninitialized memory from a semi-initialized vector.
#[kani::proof]
Expand Down
2 changes: 1 addition & 1 deletion tests/expected/uninit/vec-read-uninit/vec-read-uninit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

/// Checks that Kani catches an attempt to read uninitialized memory from an uninitialized vector.
#[kani::proof]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::ptr;
use std::ptr::addr_of;
Expand Down
2 changes: 1 addition & 1 deletion tests/kani/Uninit/access-padding-enum-multiple-variants.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::ptr;
use std::ptr::addr_of;
Expand Down
2 changes: 1 addition & 1 deletion tests/kani/Uninit/access-padding-enum-single-field.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::ptr;
use std::ptr::addr_of;
Expand Down
2 changes: 1 addition & 1 deletion tests/kani/Uninit/access-padding-enum-single-variant.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::ptr;
use std::ptr::addr_of;
Expand Down
2 changes: 1 addition & 1 deletion tests/kani/Uninit/access-padding-init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::ptr::addr_of;

Expand Down
2 changes: 1 addition & 1 deletion tests/kani/Uninit/alloc-to-slice.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::alloc::{alloc, Layout};

Expand Down
2 changes: 1 addition & 1 deletion tests/kani/Uninit/alloc-zeroed-to-slice.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::alloc::{alloc_zeroed, Layout};
use std::slice::from_raw_parts;
Expand Down
2 changes: 1 addition & 1 deletion tests/kani/Uninit/atomic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::sync::atomic::{AtomicUsize, Ordering};

Expand Down
2 changes: 1 addition & 1 deletion tests/kani/Uninit/struct-padding-and-arr-init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

use std::ptr::addr_of_mut;

Expand Down
2 changes: 1 addition & 1 deletion tests/kani/Uninit/vec-read-init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Z ghost-state -Z uninit-checks
// kani-flags: -Z uninit-checks

#[kani::proof]
fn vec_read_init() {
Expand Down

0 comments on commit b388458

Please sign in to comment.