Challenge 27: Verify Arc/Weak safety in alloc::sync with Kani#587
Challenge 27: Verify Arc/Weak safety in alloc::sync with Kani#587v3risec wants to merge 1 commit intomodel-checking:mainfrom
Conversation
|
I would like to report on the two CI failures from this PR. For
Both failures were reported as
Of these two, For
For the other failing check,
For reference, my local verification environment is:
Based on the current evidence, my impression is that these failures are more likely related to CI environment instability or resource constraints than to a semantic issue in the harnesses introduced by this PR. Would it make sense to investigate whether the CI runners are hitting memory limits, and if so, whether the memory budget or other CI resource constraints for these Kani jobs should be adjusted? |




Summary
This PR adds Kani-based verification artifacts for
Arc/Weaksafety inlibrary/alloc/src/sync.rsfor Challenge 27.The change introduces:
Arc/Weakfunctions listed in the challenge#[cfg(kani)]for those unsafe functions and a broad safe-function subsetArc<[T]>/Weak<[T]>paths can be exercised in a reusable wayNo non-verification runtime behavior is changed in normal builds.
Verification Coverage Report
Unsafe functions (required by Challenge 27)
Coverage: 12 / 12 (100%)
Verified set includes:
Arc<mem::MaybeUninit<T>,A>::assume_initArc<[mem::MaybeUninit<T>],A>::assume_initArc<T:?Sized>::from_rawArc<T:?Sized>::increment_strong_countArc<T:?Sized>::decrement_strong_countArc<T:?Sized,A:Allocator>::from_raw_inArc<T:?Sized,A:Allocator>::increment_strong_count_inArc<T:?Sized,A:Allocator>::decrement_strong_count_inArc<T:?Sized,A:Allocator>::get_mut_uncheckedArc<dyn Any+Send+Sync,A:Allocator>::downcast_uncheckedWeak<T:?Sized>::from_rawWeak<T:?Sized,A:Allocator>::from_raw_inSafe functions (Challenge 27 list)
Stable passing coverage: 54 / 58 (93.1%)
This exceeds the challenge threshold (>= 75%).
Covered safe functions (54/58), grouped by API category:
Allocation
Arc<T>::newArc<T>::new_uninitArc<T>::new_zeroedArc<T>::pinArc<T>::try_pinArc<T>::try_newArc<T>::try_new_uninitArc<T>::try_new_zeroedArc<T,A:Allocator>::new_inArc<T,A:Allocator>::new_uninit_inArc<T,A:Allocator>::new_zeroed_inArc<T,A:Allocator>::new_cyclic_inArc<T,A:Allocator>::pin_inArc<T,A:Allocator>::try_pin_inArc<T,A:Allocator>::try_new_inArc<T,A:Allocator>::try_new_uninit_inArc<T,A:Allocator>::try_new_zeroed_inArc<T,A:Allocator>::try_unwrapArc<T,A:Allocator>::into_innerArc<T:?Sized,A:Allocator>::into_inner_with_allocatorSlice
Arc<[T]>::new_uninit_sliceArc<[T]>::new_zeroed_sliceArc<[T]>::into_arrayArc<[T],A:Allocator>::new_uninit_slice_inArc<[T],A:Allocator>::new_zeroed_slice_inArcFromSlice<T: Copy>::from_sliceConversion and pointer
Arc<T:?Sized,A:Allocator>::into_raw_with_allocatorArc<T:?Sized,A:Allocator>::as_ptrArc<T:?Sized,A:Allocator>::innerArc<T:?Sized,A:Allocator>::from_box_inClone<T:?Sized, A:Allocator>::clone for ArcArc<T:?Sized+CloneToUninit, A:Allocator+Clone>::make_mutArc<T:?Sized, A:Allocator>::get_mutDrop<T:?Sized, A:Allocator>::drop for ArcArc<dyn Any+Send+Sync,A:Allocator>::downcastWeak and trait-related operations
Weak<T:?Sized,A:Allocator>::as_ptrWeak<T:?Sized,A:Allocator>::into_raw_with_allocatorWeak<T:?Sized,A:Allocator>::upgradeWeak<T:?Sized,A:Allocator>::innerDrop<T:?Sized, A:Allocator>::drop for WeakDefault and conversions
Default<T:Default>::defaultDefault<core::ffi::CStr>::defaultDefault<[T]>::defaultFrom<&str>::fromFrom<Vec<T,A:Allocator+Clone>>::fromFrom<Arc<str>>::fromUniqueArc / UniqueArcUninit and traits
UniqueArcUninit<T:?Sized, A:Allocator>::newUniqueArcUninit<T:?Sized, A:Allocator>::data_ptrDrop<T:?Sized, A:Allocator>::drop for UniqueArcUninitUniqueArc<T:?Sized,A:Allocator>::into_arcUniqueArc<T:?Sized,A:Allocator+Clone>::downgradeDeref<T:?Sized,A:Allocator>::derefDerefMut<T:?Sized,A:Allocator>::deref_mutDrop<T:?Sized, A:Allocator>::drop for UniqueArcNot yet listed as standalone harness targets (4/58)
Default<str>::defaultArcFromSlice<T: Clone>::from_sliceTryFrom<Arc<[T],A:Allocator>>::try_fromToArcSlice<T, I>::to_arc_sliceCurrent Criteria Met
Tis instantiated with representative concrete types allowed by the challenge, and allocator-focused proofs are limited to standard-library allocator scope (Global).Approach
The verification strategy combines contracts for unsafe entry points with executable proof harnesses:
kani::requirespreconditions for pointer validity, alignment soundness, same-allocation checks, and refcount well-formedness.Arcstrong/weak counters.#[kani::proof]/#[kani::proof_for_contract]modules for required unsafe functions and safe-function coverage targets.Arc<[T]>/Weak<[T]>harnesses.?Sizedslice cases without duplicating setup logic across harnesses.cfg(kani)so normal std behavior is unchanged.Scope assumptions (per challenge allowance)
i8..i128,u8..u128),bool,(), arrays, vectors, slices,str,CStr, and trait objects (dyn Any,dyn Any + Send + Syncwhere required by the API).Global.Note on data races
This PR uses Kani proof harnesses in the current single-threaded verification setting. As a result, these proofs do not model true concurrent interleavings between multiple threads.
What is verified here is that the
Arc/WeakAPIs covered by these harnesses are memory-safe under the explored single-threaded executions, including pointer validity, alignment/allocation consistency, and key strong/weak reference-count invariants.Verification
All passing harnesses listed in this report pass locally with the current Kani setup used for this repository.
Resolves #383
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.