Skip to content

Performance: common std constructs (padded integer formatting, str::parse, recursive drop, Backtrace::capture) time out #5127

Description

@feliperodri

These four constructs are common in real crates, and each one makes a harness hit a 5-minute --harness-timeout with Kani 0.68.0 (CBMC 6.11.0, nightly-2026-10-22). Each is a few lines. Kani reports only CBMC timed out; none of them fails a property.

Formatting a symbolic integer with a width

#[cfg(kani)]
#[kani::proof]
fn fmt_padded() {
    let x: u32 = kani::any();
    let s = format!("{:05}", x);
    assert!(s.len() >= 5);
}

Seen while verifying: toml_datetime 1.1.2+spec-1.1.0.

str::parse on a symbolic 10-byte string

#[cfg(kani)]
#[kani::proof]
fn parse_symbolic_10() {
    let b: [u8; 10] = kani::any();
    if let Ok(s) = core::str::from_utf8(&b) {
        let _ = s.parse::<u32>();
    }
}

#[cfg(kani)]
#[kani::proof]
#[kani::unwind(10)]
fn copy_symbolic_len() {
    let n: usize = kani::any();
    kani::assume(n <= 8);
    let src = [7u8; 8];
    let v: Vec<u8> = src[..n].to_vec();
    assert!(v.len() == n);
}

#[cfg(kani)]
#[kani::proof]
fn parse_concrete() {
    let r = "12345".parse::<u32>();
    assert!(r == Ok(12345));
}

Seen while verifying: version_check 0.9.5.

Dropping a recursive type built to a symbolic depth (at most 3)

pub enum Tree { Leaf, Node(Vec<Tree>) }

#[cfg(kani)]
#[kani::proof]
fn drop_tree_concrete() {
    let t = Tree::Node(vec![Tree::Node(vec![Tree::Leaf])]);
    drop(t);
}

#[cfg(kani)]
#[kani::proof]
fn zz_symbolic_depth_drop() {
    let d: u8 = kani::any();
    kani::assume(d <= 3);
    let mut t = Tree::Leaf;
    for _ in 0..d { t = Tree::Node(vec![t]); }
    drop(t);
}

Seen while verifying: toml_edit 0.25.17+spec-1.1.0.

Backtrace::capture()

#[cfg(kani)]
#[kani::proof]
fn bt() {
    let b = std::backtrace::Backtrace::capture();
    let _ = b.status();
}

Seen while verifying: anyhow 1.0.104.

Output, in each case:

VERIFICATION:- FAILED
CBMC timed out. You may want to rerun your proof with a larger timeout or use stubbing to reduce the size of the code the verifier reasons about.

For the recursive drop, a concrete depth-2 tree verifies in about 1 second, so the cost comes from the symbolic depth.

Possible improvements: built-in stubs or models for Backtrace::capture and integer formatting; for the others, a hint that names the expensive function.


Found in an experiment where AI agents used the Kani agent plugin (#5059) to verify 101 popular crates on crates.io. Each reproducer above was run by a triage agent with --harness-timeout 5m; we did not try longer timeouts. This text was written with AI assistance.

Activity

  1. added
    [E] Performance
    on Nov 6, 2026
  2. self-assigned this
    on Nov 6, 2026
  3. added
    [E] User Experience
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[E] Performance[E] User Experience

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions