Skip to content

Commit

Permalink
Add an unstable option to revert to old, unsound behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
zhassan-aws committed Apr 4, 2024
1 parent e370295 commit b13ad9c
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 2 deletions.
3 changes: 3 additions & 0 deletions kani-compiler/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ pub struct Arguments {
/// Enable specific checks.
#[clap(long)]
pub ub_check: Vec<ExtraChecks>,
/// Ignore storage markers.
#[clap(long)]
pub ignore_storage_markers: bool,
}

#[derive(Debug, Clone, Copy, AsRefStr, EnumString, VariantNames, PartialEq, Eq)]
Expand Down
14 changes: 12 additions & 2 deletions kani-compiler/src/codegen_cprover_gotoc/codegen/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,19 @@ impl<'tcx> GotocCtx<'tcx> {
self.codegen_set_discriminant(dest_ty, dest_expr, *variant_index, location)
}
StatementKind::StorageLive(var_id) => {
Stmt::decl(self.codegen_local(*var_id), None, location)
if self.queries.args().ignore_storage_markers {
Stmt::skip(location)
} else {
Stmt::decl(self.codegen_local(*var_id), None, location)
}
}
StatementKind::StorageDead(var_id) => {
if self.queries.args().ignore_storage_markers {
Stmt::skip(location)
} else {
Stmt::dead(self.codegen_local(*var_id), location)
}
}
StatementKind::StorageDead(var_id) => Stmt::dead(self.codegen_local(*var_id), location),
StatementKind::Intrinsic(NonDivergingIntrinsic::CopyNonOverlapping(
CopyNonOverlapping { src, dst, count },
)) => {
Expand Down
8 changes: 8 additions & 0 deletions kani-driver/src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ pub struct VerificationArgs {
#[arg(long, hide_short_help = true, requires("enable_unstable"))]
pub ignore_global_asm: bool,

/// Ignore lifetimes of local variables. This effectively extends their
/// lifetimes to the function scope, and hence may cause Kani to miss
/// undefined behavior resulting from using the variable after it dies.
/// This option may impact the soundness of the analysis and may cause false
/// proofs and/or counterexamples
#[arg(long, hide_short_help = true, requires("enable_unstable"))]
pub ignore_locals_lifetime: bool,

/// Write the GotoC symbol table to a file in JSON format instead of goto binary format.
#[arg(long, hide_short_help = true)]
pub write_json_symtab: bool,
Expand Down
4 changes: 4 additions & 0 deletions kani-driver/src/call_single_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ impl KaniSession {
flags.push("--ub-check=validity".into())
}

if self.args.ignore_locals_lifetime {
flags.push("--ignore-storage-markers".into())
}

flags.extend(self.args.common_args.unstable_features.as_arguments().map(str::to_string));

// This argument will select the Kani flavour of the compiler. It will be removed before
Expand Down
5 changes: 5 additions & 0 deletions tests/perf/btreeset/insert_any/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

# Temporarily ignore the handling of storage markers till
# https://github.com/model-checking/kani/issues/3099 is fixed
[package.metadata.kani]
flags = { ignore-locals-lifetime = true, enable-unstable = true }
5 changes: 5 additions & 0 deletions tests/perf/btreeset/insert_multi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

# Temporarily ignore the handling of storage markers till
# https://github.com/model-checking/kani/issues/3099 is fixed
[package.metadata.kani]
flags = { ignore-locals-lifetime = true, enable-unstable = true }
5 changes: 5 additions & 0 deletions tests/perf/btreeset/insert_same/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

# Temporarily ignore the handling of storage markers till
# https://github.com/model-checking/kani/issues/3099 is fixed
[package.metadata.kani]
flags = { ignore-locals-lifetime = true, enable-unstable = true }
1 change: 1 addition & 0 deletions tests/perf/btreeset/insert_same/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//! The test is from <https://github.com/model-checking/kani/issues/2022>
//! With CBMC's default solver (minisat), it takes ~517 seconds
//! With Kissat 3.0.0, it takes ~22 seconds
//! It started failing after <https://github.com/model-checking/kani/pull/3080>
use std::collections::BTreeSet;

Expand Down
5 changes: 5 additions & 0 deletions tests/perf/hashset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ description = "Verify HashSet basic behavior"

[package.metadata.kani.unstable]
stubbing = true

# Temporarily ignore the handling of storage markers till
# https://github.com/model-checking/kani/issues/3099 is fixed
[package.metadata.kani]
flags = { ignore-locals-lifetime = true, enable-unstable = true }

0 comments on commit b13ad9c

Please sign in to comment.