Skip to content

High memory usage with a simple string vector example #1673

@zhassan-aws

Description

@zhassan-aws

I tried this code:

const N: usize = 9;

#[cfg_attr(kani, kani::proof, kani::unwind(10))]
fn main() {
    let mut v: Vec<String> = Vec::new();
    for _i in 0..N {
        v.push(String::from("ABC"));
    }
    assert_eq!(v.len(), N);
    let index: usize = kani::any();
    kani::assume(index < v.len());
    let x = &v[index];
    assert_eq!(*x, "ABC");
}

using the following command line invocation:

kani push_string.rs

with Kani version: 0fa9ee3

This finished in ~8.5 minutes and used ~23 GB of memory:

image

Although at some point, memory usage went up to ~27 GB.

If I bump N to 10 (and unwind to 11), it runs out of memory (>32 GB).

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-CBMCIssue related to an existing CBMC issue[C] BugThis is a bug. Something isn't working.[E] PerformanceTrack performance improvement (Time / Memory / CPU)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions