You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Autoharness: Fn-bound closure models have no side effects, so callbacks that modify shared state are not covered #4994
Autoharness instantiates Fn/FnMut/FnOnce-bounded type parameters with the nondet_fn* models (#4726). Each call returns a fresh nondeterministic value, which covers every value a real closure could return. The models have no side effects, though, so if a function's correctness depends on its callback not modifying state the function can also observe, autoharness reports Success even when a real callback breaks it.
Reproducer:
use std::cell::Cell;/// Assumes the callback never changes `c`.pubfncall_and_check_cell<F:Fn()>(c:&Cell<u8>,g:F){let before = c.get();g();assert_eq!(before, c.get(),"callback changed the cell");}#[cfg(kani)]mod proofs {usesuper::*;#[kani::proof]fnreal_closure_breaks_cell(){let c = Cell::new(0u8);call_and_check_cell(&c, || c.set(c.get().wrapping_add(1)));}}
The manual harness real_closure_breaks_cell fails with "callback changed the cell".
The same happens when the shared state is a static (e.g. a callback that increments a global AtomicU8 the function reads before and after the call).
This is related to #4750: the state is shared between an argument and the closure's captures, a kind of caller-controlled aliasing that the argument-aliasing work does not cover.
The doc comment on the models in library/kani/src/arbitrary.rs says they cover the function-under-test's own code "for any closure behavior". That holds for return values, but not for side effects.
Until this is modeled, the autoharness reference page will list it among the soundness caveats (#4991).
Activity
Fill in the soundness caveats of the autoharness reference page
Polish the autoharness reference page for consistency
Restructure and update the autoharness reference page (model-checking…