Repository navigation
Description
Summary
#4836 stops Kani from crashing on variadic functions whose calling convention is not the C one, but it does so by declaring them unsupported: calls report an unsupported construct, and autoharness skips them with AutoHarnessSkipReason::UnsupportedVariadic. That is the honest short-term answer; this issue tracks actually supporting them, and the neighbouring gap that autoharness cannot harness any variadic.
Gap 1: non-C calling conventions are unsupported
On x86-64, rustc accepts C-variadics with extern "sysv64" as a naked definition or a foreign declaration:
#[unsafe(naked)]
unsafe extern "sysv64" fn variadic_sysv64(_: ...) -> u32 {
core::arch::naked_asm!("")
}
unsafe extern "sysv64" {
fn foreign_variadic_sysv64(a: u32, _: ...) -> u32;
}Kani now reports "Variadic function with a non-C calling convention is not currently supported by Kani" for calls to either. Supporting them needs, in order:
- Upstream first.
rustc_public's stableFnAbiconversion asserts the convention isCanonAbi::C, so Kani cannot even ask for the ABI — filed as rustc_public: stableFnAbiconversion ICEs onextern "sysv64"C-variadics rust-lang/rust#163233. Until that is resolved, Kani only knows these functions exist via the internalFnAbi(kani_middle::is_unsupported_variadic). - Then the goto backend, which would need to represent the calling convention for CBMC. Note CBMC's variadic support is what it is;
extern "C"variadics work today (tests/kani/FunctionCall/Variadic), so the question is how much of that carries over.
Worth noting this is x86-64 only: on aarch64 "sysv64" is not a supported ABI for the current target, so there is nothing to support there.
Gap 2: autoharness cannot harness any variadic, including C ones
Independent of the calling convention, autoharness skips every variadic with
"Missing Arbitrary implementation for argument(s) _: std::ffi::VaList<'_>", because Kani has no way to generate a VaList. Kani can verify a hand-written harness that calls a C-variadic with concrete arguments — see tests/kani/FunctionCall/Variadic — so the missing piece is argument generation, not the call.
Supporting this means deciding what a nondeterministic variadic call even means: how many arguments, of which types. A bounded model (e.g. "up to N arguments of the fixed types the callee reads") is the only thing that makes sense, and VaList would need a Kani model rather than an Arbitrary implementation.
Priority
Low: both shapes are rare in the code people verify, and the failure modes are now honest (an unsupported construct that fails only if reachable, and a skip with an accurate reason) rather than a crash. Filed so the workaround in #4836 is not mistaken for the intended end state.
Activity
Report variadic functions with a non-C ABI as unsupported (model-chec…