Skip to content

Commit adc1f0d

Browse files
authored
Do not turn trivially diverging loops into assume(false) (rust-lang#3223)
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. Resolves: rust-lang#2909
1 parent ffcb5ad commit adc1f0d

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

kani-driver/src/call_cbmc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ impl KaniSession {
182182
}
183183

184184
if self.args.checks.unwinding_on() {
185+
// TODO: With CBMC v6 the below can be removed as those are defaults.
185186
args.push("--unwinding-assertions".into());
187+
args.push("--no-self-loops-to-assumptions".into());
186188
}
187189

188190
if self.args.extra_pointer_checks {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Failed Checks: unwinding assertion loop 0
2+
3+
VERIFICATION:- FAILED
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// kani-flags: -Zfunction-contracts
4+
5+
#[kani::ensures(|result : &i32| *result == 1)]
6+
fn foo() -> i32 {
7+
loop {}
8+
2
9+
}
10+
11+
#[kani::proof_for_contract(foo)]
12+
#[kani::unwind(1)]
13+
fn check_foo() {
14+
let _ = foo();
15+
}

0 commit comments

Comments
 (0)