Skip to content

Kani gives wrong result if two harnesses have the same name #1974

Closed

Description

@celinval

Here are the steps to reproduce them:

  1. Create two crates, and add a harness to each of them with the same name, e.g.:
cargo init --lib lib1
cargo init --lib lib2

Where lib1/src/lib.rs include:

#[kani::proof]
fn check_lib() {
    assert!(1 == 1, "This should succeed");
}

And lib2/src/lib.rs include:

#[kani::proof]
fn check_lib() {
    assert_eq!(1 + 1, 1, "This should fail");
}
  1. Create a workspace that includes both crates:
[workspace]
members = [
  "lib1",
  "lib2",
]
  1. Run cargo kani in the workspace.

with Kani version: 0.16.0

I expected to see this happen: Kani should report that one harness failed and one succeeded.

Instead, this happened: Kani claims that both harnesses succeed.

$ cargo kani --output-format=terse
   Compiling lib1 v0.1.0 (/tmp/ws-name-conflict/lib1)
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
   Compiling lib2 v0.1.0 (/tmp/ws-name-conflict/lib2)
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
Checking harness check_lib...

VERIFICATION RESULT:
 ** 0 of 1 failed

VERIFICATION:- SUCCESSFUL
Verification Time: 0.01958095s

Checking harness check_lib...

VERIFICATION RESULT:
 ** 0 of 1 failed

VERIFICATION:- SUCCESSFUL
Verification Time: 0.019129628s

Complete - 2 successfully verified harnesses, 0 failures, 2 total.

Activity

  1. added
    [C] Bug
    [F] Soundness
    on Dec 7, 2022
  2. self-assigned this
    on Dec 7, 2022
  3. moved this to In Progress in Kani 0.17on Dec 7, 2022
  4. Repository owner moved this from In Progress to Done in Kani 0.17on Dec 15, 2022
  5. added this to the Autoharness milestone on Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[C] Bug[F] Soundness

Type

No type

Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions