Repository navigation
Closed
Labels
[C] BugThis is a bug. Something isn't working.
Description
The current instructions for the concrete playback feature include adding kani in the dev-dependencies section. If the harness of interest is under #[cfg(test)], then cargo kani needs to be run with the --tests option. However, including --tests results in trying to compile the Kani crate with Kani! This fails with the following error:
error: duplicate diagnostic item found: `KaniAssume`.
--> /home/ubuntu/.cargo/git/checkouts/kani-0ce0dacf5e98886d/499e35f/library/kani/src/lib.rs:44:1
|
44 | pub fn assume(_cond: bool) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the diagnostic item is first defined in crate `kani`.
error: duplicate diagnostic item found: `KaniExpectFail`.
--> /home/ubuntu/.cargo/git/checkouts/kani-0ce0dacf5e98886d/499e35f/library/kani/src/lib.rs:122:1
|
122 | pub fn expect_fail(_cond: bool, _message: &'static str) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the diagnostic item is first defined in crate `kani`.
error: duplicate diagnostic item found: `KaniAssert`.
--> /home/ubuntu/.cargo/git/checkouts/kani-0ce0dacf5e98886d/499e35f/library/kani/src/lib.rs:61:1
|
61 | pub fn assert(_cond: bool, _msg: &'static str) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the diagnostic item is first defined in crate `kani`.
error: duplicate diagnostic item found: `KaniAnyRaw`.
--> /home/ubuntu/.cargo/git/checkouts/kani-0ce0dacf5e98886d/499e35f/library/kani/src/lib.rs:115:1
|
115 | fn any_raw_inner<T>() -> T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the diagnostic item is first defined in crate `kani`.
error: duplicate diagnostic item found: `KaniPanic`.
--> /home/ubuntu/.cargo/git/checkouts/kani-0ce0dacf5e98886d/499e35f/library/kani/src/lib.rs:137:1
|
137 | pub fn panic(message: &'static str) -> ! {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the diagnostic item is first defined in crate `kani`.
Error: "Failed to compile crate."
error: could not compile `kani` due to 5 previous errors
Error: cargo exited with status exit status: 101
The workaround I've used is to remove kani from the dev-dependencies, before running cargo kani, then add it back before running debugging the generated harness.
Steps to reproduce:
cargo new --lib conc_playbackcd conc_playback- Add
kanitodev-dependenciesinCargo.toml:
[dev-dependencies]
kani = { git = "https://github.com/model-checking/kani", features = ["concrete_playback"] }- Run
cargo kani --tests
Metadata
Metadata
Assignees
Labels
[C] BugThis is a bug. Something isn't working.
Activity
zhassan-aws commentedon Aug 23, 2022
One easy fix is to update the instructions to suggest conditionally adding
kanias a dev dependency:celinval commentedon Aug 31, 2022
That's an interesting one... There's definitely a conflict between
--testsand--concrete-playback.It feels a bit counter intuitive to add
kaniundercfg(not(kani)). Another issue is that the--concrete-playbackfeature adds the test case in the same module as the proof harness. So this fix wouldn't work if the harness is inside a module guarded with#[cfg(kani)]:jaisnan commentedon Jan 31, 2023
Ran into this issue while adding the concrete playback button for the extension, this causes all cfg(test) or #[test] cases to crash and it gives the same underlying error.
carolynzech commentedon Feb 5, 2025
I've confirmed that #2464 did indeed fix this.
Steps:
If you don't change the contents of
src/lib.rsat all, Kani just exits with a message that there were no harnesses. I added a failing harness and tested thatcargo kani --tests --concrete-playback inplace -Z concrete-playbackgenerates a failing test andcargo kani playbackplays it back correctly.