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
Failed to stub_verified contracts with slices in kani::modifies #3682
Still reproducible at d4df833c (0.67.0-dev, 2026-01-18), and it looks like #4749 ("Fix compiler crash on slice-modifies verified stubs", closing #4748) fixed the same root cause: AnyModifiesPass::replace_any_modifies resolved write_any_slice with the generic args of write_any::<[T]>, i.e. with [T] as the element type, which is where the IntoIterator::into_iter for &mut [[u8]] resolution failure came from.
Minimal reproducer at d4df833c (kani t.rs -Z function-contracts -Z mem-predicates), same reachability.rs panic as above:
structD{buf:Vec<u8>}implD{fncap(&self) -> usize{self.buf.len()}fnptr(&mutself) -> *mutu8{self.buf.as_mut_ptr()}#[kani::requires(n <= self.cap() && dst <= self.cap() - n)]#[kani::ensures(|_| *written == old(*written) + n)]#[kani::modifies(written, core::ptr::slice_from_raw_parts_mut(self.ptr().add(dst), n))]unsafefnfill(&mutself,dst:usize,n:usize,written:&mutusize){for i in0..n {unsafe{self.ptr().add(dst + i).write(1)};}*written += n;}unsafefnfill_twice(&mutself,n:usize) -> usize{letmut w = 0;let a = n.min(self.cap());unsafe{self.fill(0, a,&mut w)};unsafe{self.fill(0, a,&mut w)};
w
}}#[kani::proof_for_contract(D::fill)]#[kani::unwind(5)]fncheck_fill(){let cap:usize = kani::any();
kani::assume(cap <= 3);letmut d = D{buf:vec![0u8; cap]};letmut w = 0;unsafe{ d.fill(kani::any(), kani::any(),&mut w)};}#[kani::proof]#[kani::stub_verified(D::fill)]fncheck_fill_twice(){let cap:usize = kani::any();
kani::assume(cap <= 1 << 20);letmut d = D{buf:vec![0u8; cap]};let w = unsafe{ d.fill_twice(kani::any())};assert!(w <= 2* cap);}
This probably can be closed as fixed by #4749 (I have not rebuilt a post-#4749 Kani to confirm on this exact reproducer).
With Kani 0.68.0, the original reproducer no longer crashes the compiler. After adding the now-required #[kani::proof_for_contract(modify_slice)] harness, kani -Zfunction-contracts -Zstubbing test_stubbing.rs reports VERIFICATION:- SUCCESSFUL for test_stubbing (and for the contract proof). A negative harness asserting an element is unchanged after the verified stub fails as expected. This was fixed by #4749 (in 0.68.0), so closing.
Activity
jrey8343 commentedon Sep 8, 2026
Still reproducible at
d4df833c(0.67.0-dev, 2026-01-18), and it looks like #4749 ("Fix compiler crash on slice-modifies verified stubs", closing #4748) fixed the same root cause:AnyModifiesPass::replace_any_modifiesresolvedwrite_any_slicewith the generic args ofwrite_any::<[T]>, i.e. with[T]as the element type, which is where theIntoIterator::into_iterfor&mut [[u8]]resolution failure came from.Minimal reproducer at
d4df833c(kani t.rs -Z function-contracts -Z mem-predicates), samereachability.rspanic as above:This probably can be closed as fixed by #4749 (I have not rebuilt a post-#4749 Kani to confirm on this exact reproducer).
feliperodri commentedon Sep 25, 2026
With Kani 0.68.0, the original reproducer no longer crashes the compiler. After adding the now-required
#[kani::proof_for_contract(modify_slice)]harness,kani -Zfunction-contracts -Zstubbing test_stubbing.rsreportsVERIFICATION:- SUCCESSFULfortest_stubbing(and for the contract proof). A negative harness asserting an element is unchanged after the verified stub fails as expected. This was fixed by #4749 (in 0.68.0), so closing.