Repository navigation
Description
CBMC 6.11.0 stops with a std::out_of_range exception (map::at, reported by CBMC's top-level exception handler, exit status 6) during SMT2 conversion of a goto program produced by Kani for a Rust harness that formats a value. It happens with --z3 and --cvc5, but not with plain --smt2 --outfile.
The Rust harness (Kani main at 328e6b8):
#[kani::proof]
#[kani::solver(z3)]
fn format_z3() {
let x: u8 = kani::any();
let s = format!("{}", x);
assert!(s.len() <= 3);
}kani min2.rs reports map::at and CBMC failed with status 6. The same happens for a harness that only calls char::encode_utf8 into a 2-byte buffer, whose panic path formats a message. A reachable panic!("x = {}", x) does not crash (presumably because Kani does not model the formatting for its own panic handling; not checked).
With the goto binary that Kani produced (--keep-temps; attached gzipped as format_z3.goto.gz in the first comment) and the flags Kani passes (--verbose), plain CBMC reproduces it:
$ cbmc --no-malloc-may-fail --no-undefined-shift-check --no-signed-overflow-check --nan-check \
--no-self-loops-to-assumptions --no-pointer-primitive-check --object-bits 16 --slice-formula \
--z3 format_z3.goto
...
Passing problem to SMT2 QF_AUFBV using Z3
converting SSA
map::at
$ echo $?
6
| back end | result |
|---|---|
--z3 |
map::at, exit 6 |
--cvc5 |
map::at, exit 6 |
--z3 --outfile f.smt2 |
map::at, exit 6 |
--smt2 --outfile f.smt2 |
exit 0, formula written |
I did not run the default SAT back end on this binary.
The partial formula from --z3 --outfile ends inside a datatype declaration whose first field is buf, right after the datatype with fields flags, width and precision:
(declare-datatypes ((struct.45 0)) (((mk-struct.45 (struct.45.flags (_ BitVec 32)) (struct.45.width (_ BitVec 16)) (struct.45.precision (_ BitVec 16)) ))))
...
(declare-datatypes ((struct.44 0)) (((mk-struct.44 (struct.44.buf
These match Rust's core::fmt::FormattingOptions and core::fmt::Formatter. In the goto symbol table, Formatter is
struct _2234...3627 { struct _2415...1032::FatPtr buf; struct _8202...2194 options; }
with buf of type dyn std::fmt::Write::FatPtr:
struct _2415...1032::FatPtr { _2415...1032Inner *data; struct _2415...1032::vtable *vtable; }
The cut-off point is only an indication; my guess (not verified) is that the sort of the buf field is looked up in datatype_map before that struct type has been declared. smt2_conv.cpp has several datatype_map.at(...) calls; I have not identified which one throws. A hand-written C program with structs of the same shape (an incomplete Inner type behind the data pointer, a vtable pointer, and a struct of three integer fields) verifies normally with --z3.
#5297 (closed in 2021) reported a map::at exception (map::at: key not found) when converting structs to SMT2, with a different trigger.
Environment
CBMC 6.11.0 (release binary), z3 5.1.0, cvc5 1.3.0, x86_64 Linux. Goto binary from Kani main at 328e6b8 (rustc nightly-2026-10-11). I did not build or run CBMC develop; smt2_conv.cpp has changed there since 6.11.0.
Activity
Talha-Dmr commentedon Oct 14, 2026
The goto binary that Kani produced for
format_z3(--keep-temps), gzipped:format_z3.goto.gz
feliperodri commentedon Nov 11, 2026
Another trigger that doesn't involve
format!, same signature (CBMC 6.11.0, Kanimain@ bf9c58e). It happens with z3 5.3.1 and with 5.4.0, and not with--smt2 --outfile.cargo kani -Z quantifiers:converting SSA→map::at→CBMC failed with status 6.Running
cbmc ... --z3 <goto>directly on the--keep-tempsbinary crashes the same way.cbmc ... --smt2 --outfile x.smt2 <goto>completes.The SAT backend also completes. Interestingly, the unbounded variant (slice from a symbolic-size allocation instead of a 4-element array) does not crash.
Vec::to_vecreachesalloc::raw_vec::handle_error/handle_alloc_error, whose panic paths format messages. So this may be the samecore::fmtconstruct you identified.SMT2: declare datatypes of pointed-to structs after the pointing struct
linux: SMT2 map::at reduced and fixed -- a pointer into a by-value co…