Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kani fails to detect for loop bound after upgrade to nightly-2024-03-15 #3088

Open
celinval opened this issue Mar 18, 2024 · 2 comments
Open
Labels
[C] Bug This is a bug. Something isn't working. T-CBMC Issue related to an existing CBMC issue T-High Priority Tag issues that have high priority

Comments

@celinval
Copy link
Contributor

While upgrading to nightly-2024-03-15, we had to add a few #[kani::unwind] attributes to harnesses with for loops with simple integer ranges. We need to investigate why this is no longer the case, and hopefully improve the loop bound detection algorithm.

Here is an example of a test case (tests/expected/iterator/main.rs):

#[kani::proof]
#[kani::unwind(4)] // Kani will unwind forever if we remove this attribute.
fn main() {
    let mut z = 1;
    for i in 1..4 {
        z *= i;
    }
    assert!(z == 6);
}

using the following command line invocation:

kani main.rs

with Kani version: #3084

I expected to see this happen: Kani should be able to automatically detect the loop bound.

Instead, this happened: Kani requires an unwind attribute.

@celinval celinval added [C] Bug This is a bug. Something isn't working. T-High Priority Tag issues that have high priority labels Mar 18, 2024
celinval added a commit that referenced this issue Mar 18, 2024
Note that with this upgrade Kani can no longer automatically detect loop bounds when using range.

For more details, see: #3088
@OliverKillane
Copy link

This appears to also affect incredibly simple cases like:

#[kani::proof]
fn check() {
  for _ in 0..1 {}
}

Note 0..0 still works

@tautschnig
Copy link
Member

With apologies for not actually posting on this issue: diffblue/cbmc#8247 fixes this problem on the CBMC side. We just need to get this merged plus a new CBMC release to be produced.

@celinval celinval added the T-CBMC Issue related to an existing CBMC issue label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Bug This is a bug. Something isn't working. T-CBMC Issue related to an existing CBMC issue T-High Priority Tag issues that have high priority
Projects
None yet
Development

No branches or pull requests

3 participants