Skip to content

cargo kani autoharness's default --default-unwind 20 silently applies to pre-existing manual harnesses too, causing spurious failures #5103

Closed

Description

@feliperodri

Kani version: 0.68.0 (main @ cd355b0).

What happens

kani-driver/src/autoharness/mod.rs:

const LOOP_UNWIND_DEFAULT: u32 = 20;
...
pub fn add_default_bounds(&mut self) {
    if self.args.harness_timeout.is_none() { ... }
    if self.args.default_unwind.is_none() {
        self.args.default_unwind = Some(LOOP_UNWIND_DEFAULT);
    }
}

This is documented as existing "to prevent automatic harnesses from hanging," but default_unwind is a session-wide CLI argument. It also lowers the effective unwinding bound for every pre-existing manual harness compiled in the same invocation that has no explicit #[kani::unwind(N)] of its own — even when --include-pattern/--harness is used to target only the automatically generated harnesses. Manual harnesses are still compiled and run alongside them (see also #4939, a related debug-build-only crash in that same code path), and now run with a bound they never asked for.

Reproduction

hifitime has a pre-existing, unbounded manual harness:

#[kani::proof]
#[kani::stub(crate::epoch::system_time::duration_since_unix_epoch, stub_duration_since_unix_epoch)]
fn kani_harness_Epoch_now() { ... }

which calls Epoch::leap_seconds_with, whose loop is over a fixed-size static leap-second table with more than 20 entries (a for leap_second in provider.rev(), noted in-source as unsupported by Kani's loop contracts, relying on plain unwinding instead):

$ cargo kani --harness kani_harness_Epoch_now -Z stubbing
VERIFICATION:- SUCCESSFUL

$ cargo kani autoharness -Z autoharness -Z stubbing --include-pattern duration::
...
Thread 1: Checking harness epoch::kani_verif::kani_harnesses::kani_harness_Epoch_now...
Thread 1: Failed Checks: unwinding assertion loop 0
Thread 1:  File: "src/epoch/mod.rs", line 147, in epoch::Epoch::leap_seconds_with::<epoch::leap_seconds::LatestLeapSeconds>
Thread 1: VERIFICATION:- FAILED

The --include-pattern duration:: filter has nothing to do with epoch::; the harness still runs (as a manual harness) and still fails, purely because of the implicit --default-unwind 20.

Expected

autoharness should only apply its default timeout/unwind bound to the harnesses it generates, not to manual harnesses already in the crate — e.g. by using a per-harness bound for generated harnesses rather than a blanket CLI-wide default_unwind, or by warning (as it already does for --slice-bound/--string-bound reaching the unwind bound in warn_if_bounds_reach_unwind) when a manual harness's result changes because of the injected default.

Impact

A project that mixes manual harnesses with autoharness (as the references/autoharness.md skill doc in the agent plugin recommends) can get a previously-green manual harness reported as failing, for a reason entirely unrelated to the code under test. Since --unwinding-assertions is on, this fails safe (FAILED, not a false SUCCESS) — but it's still a misleading, non-reproducible-outside-autoharness result.

Activity

  1. added this to the Autoharness milestone on Oct 31, 2026
  2. added
    [F] Spurious Failure
    Z-Autoharness
    [C] Bug
    T-High Priority
    on Oct 31, 2026
  3. added theissue type on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-High PriorityZ-Autoharness[C] Bug[F] Spurious Failure

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions