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
Replace-mode stubs drop an owned receiver even when the real body moves it out #5118
[C] BugThis is a bug. Something isn't working.[F] SoundnessKani failed to detect an issue[F] Spurious FailureIssues that cause Kani verification to fail despite the code being correct.
Found while reviewing #4985 (owned-receiver contracts on const fn).
Problem
In replace mode, a stub from #[kani::stub_verified] always drops an owned receiver, even when the real body moves it out and never drops it.
structOwned(u32);implDropforOwned{fndrop(&mutself){DROPS.fetch_add(1,Ordering::Relaxed);}}implOwned{#[kani::ensures(|result:&Owned| result.0 == old(self.0))]fnid(self) -> Owned{self}// moves `self` out; the real body never drops it}#[kani::proof]#[kani::stub_verified(Owned::id)]fncheck_stub_does_not_drop_moved_receiver(){let v:u32 = kani::any();let o = Owned(v).id();assert!(o.0 == v);assert!(DROPS.load(Ordering::Relaxed) == 0);// FAILS: the stub drops the receiver}
With the real body, DROPS stays 0. Under the stub it is 1, so the harness fails. A harness that depends on the number of drops can therefore report a spurious failure, or pass when it shouldn't.
Document the limitation in the contracts reference, so users know that a verified stub's receiver is always dropped.
Longer term: make the replace stub drop the receiver only when the body does not move it out (or pin the behaviour with a test that matches the real body's drop).
Reproduced on 8e09e0756 (#4985 head) and on the main base.
[C] BugThis is a bug. Something isn't working.[F] SoundnessKani failed to detect an issue[F] Spurious FailureIssues that cause Kani verification to fail despite the code being correct.
Activity