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

Spurious capacity overflow with CBMC 5.71 #1946

Closed
zhassan-aws opened this issue Nov 28, 2022 · 4 comments · Fixed by #1941
Closed

Spurious capacity overflow with CBMC 5.71 #1946

zhassan-aws opened this issue Nov 28, 2022 · 4 comments · Fixed by #1941
Assignees
Labels
[C] Bug This is a bug. Something isn't working. T-CBMC Issue related to an existing CBMC issue

Comments

@zhassan-aws
Copy link
Contributor

This test is derived from https://github.com/model-checking/kani/blob/main/tests/kani/Refs/main.rs

I tried this code:

use std::collections::BTreeMap;

#[kani::proof]
#[kani::unwind(2)]
fn main() {
    let arguments: BTreeMap<(), ()> = BTreeMap::new();
    let _ = arguments.values().collect::<Vec<_>>()
            .into_iter()
            .map(|_| 5)
            .collect::<Vec<_>>();
}

using the following command line invocation:

kani btreemap.rs

with Kani version: bb268b1 and CBMC 5.71.0

I expected to see this happen: Verification successful

Instead, this happened: a capacity overflow check fails:

SUMMARY:
 ** 1 of 1148 failed (15 unreachable)
Failed Checks: This is a placeholder message; Kani doesn't support message formatted at runtime
 File: "/home/ubuntu/.rustup/toolchains/nightly-2022-11-06-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/raw_vec.rs", line 518, in alloc::raw_vec::capacity_overflow

VERIFICATION:- FAILED
Verification Time: 3.296982s

With CBMC 5.70.0, this test passes:

SUMMARY:
 ** 0 of 1151 failed (20 unreachable)

VERIFICATION:- SUCCESSFUL
Verification Time: 44.638622s
@zhassan-aws zhassan-aws added the [C] Bug This is a bug. Something isn't working. label Nov 28, 2022
@zhassan-aws
Copy link
Contributor Author

Blocker for #1941

@tautschnig
Copy link
Member

This is also happening with the very latest CBMC version (which has additional fixes on top of 5.71.0). I'll investigate.

@tautschnig tautschnig self-assigned this Nov 28, 2022
@tautschnig
Copy link
Member

The CBMC change altering the result is diffblue/cbmc@633875b. As a consequence of this change we no longer simplify (struct Unit **)8 - (struct Unit **)8 to zero, but instead leave the expression intact. It seems the back-end isn't handling this correctly (even though we should likely put back a variant of the previous simplification rule).

@tautschnig
Copy link
Member

diffblue/cbmc#7398 addresses this problem.

@zhassan-aws zhassan-aws added the T-CBMC Issue related to an existing CBMC issue label Dec 3, 2022
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants