Skip to content

Commit

Permalink
Do not turn trivially diverging loops into assume(false)
Browse files Browse the repository at this point in the history
CBMC's symbolic execution by default turns `while(true) {}` loops into
`assume(false)` to counter trivial non-termination of symbolic
execution. When unwinding assertions are enabled, however, we should
report the non-termination of such loops.
  • Loading branch information
tautschnig committed Jun 4, 2024
1 parent 7bf23a2 commit b32df89
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions kani-driver/src/call_cbmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl KaniSession {

if self.args.checks.unwinding_on() {
args.push("--unwinding-assertions".into());
args.push("--no-self-loops-to-assumptions".into());
}

if self.args.extra_pointer_checks {
Expand Down
3 changes: 3 additions & 0 deletions tests/expected/function-contract/diverging_loop.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Failed Checks: unwinding assertion loop 0

VERIFICATION:- FAILED
11 changes: 11 additions & 0 deletions tests/expected/function-contract/diverging_loop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#[kani::ensures(result == 1)]
fn foo() -> i32 {
loop {};
2
}

#[kani::proof_for_contract(foo)]
#[kani::unwind(1)]
fn check_foo() {
let _ = foo();
}

0 comments on commit b32df89

Please sign in to comment.