Repository navigation
Conversation
Verification updateThe audited local matrix covers 785/785 typed harnesses and 14/14 auxiliary proofs, including all 63 typed
Toolchain follow-upThe submitted fixes cover ZST pointer identity and early lowering of native assertion failures. The exact PR heads build together on Kani main Replaying both fixes on the compatible Kani pin Both fixes are open upstream. Hosted checks need a compatible pin that contains them. The verification notes record the type, const-width, allocation and UB-model boundaries for review. Kani #5202, Kani #5203 |
|
Restored the three original Preserved the upstream harness coverage with 44 retained regressions and 28 symbolic replacements. All 44 retained regressions passed on the clean project pin |
|
I updated The earlier The remaining four failures are CBMC 6.11.0 |
|
@feliperodri I've completed Challenge 18 and updated the PR description with the verification results and remaining limitations. Could you please take a look when you have a chance? I'd appreciate your feedback. Thanks! |
Summary
The suite checks all 82 distinct listed methods present in this Std snapshot across seven concrete element types. The audited local results record passes for 785 typed harnesses and 14 auxiliary proofs, including all 63 typed
nth_backharnesses. Slice lengths, chunk sizes, cursor positions and skip counts are symbolic.The changes are confined to
library/core/src/slice/iter.rs,library/core/src/slice/iter/macros.rsandlibrary/core/src/ptr/mut_ptr.rs. The first two files hold the iterator harnesses, contracts and loop annotations. The third adds the contract for the raw split callee. All 208 production iterator bodies match the base after stripping proof annotations and Kani-only ghost state. The raw split body also matches the base.Two groups in the local suite depend on Kani fixes for ZST offset lowering and native assertion failures. Kani #5202 · Kani #5203
Element types
u8bool[u8; 3]Paddedrepr(C)layout with padding and distinct size and alignmentAlignedWord()usize::MAXAlignedZstThe harness macros share the proof logic across these layouts.
[u8; 3]is the element type. Its slice length remains symbolic.Harnesses
Each listed method executes its real implementation. The table counts method-and-implementation pairs. Each pair has evidence at all seven element types. The
ArrayWindowsinstantiations also vary the const width.Part 1 — Iterator macros
IterandIterMutfromiterator!make_slice,len,is_empty,next,size_hint,count,nth,advance_by,last,fold,for_each,position,rposition,next_back,nth_back,advance_back_bySplitN,SplitNMut,RSplitNandRSplitNMutfromforward_iterator!nextandsize_hintfor each implementationcheck_new_and_querieschecks construction and the cursor queries onIterandIterMut. The step and loop harnesses check the remaining view, the returned reference or exhaustion, and the admissible writes. Separate ZSTsize_hintharnesses exercise the checked-overflow path for unfinished splits with maximal length.Part 2 — Safe methods
IternewIterMutnew,into_slice,as_mut_sliceSplitnext,next_backChunksnext_backChunksMutnext,nth,next_back,nth_backChunksExactandRChunksExactnewfor each implementationChunksExactMutandRChunksExactMutnew,next,nth,next_back,nth_backfor each implementationArrayWindowsnext,nth,next_back,nth_back, at widths 1, 2 and 4RChunksnext,next_backRChunksMutnext,nth,last,next_back,nth_backThese proofs cover in-range and exhausted calls. Where applicable, they check the returned pointer and length, containment within the input, disjoint mutable regions and access to the returned elements.
Part 2 — Unchecked getters
Eight existing listed implementations of
__iterator_get_uncheckedhave nativeproof_for_contractharnesses namedcheck_get_unchecked_contractin their corresponding type and iterator modules. The implementations areWindows,Chunks,ChunksMut,ChunksExact,RChunks,RChunksMut,RChunksExactandRChunksExactMut. The proofs supply the legal index, execute the getter, and check its return region and write frame.The challenge table has two
ChunksExactrows.ArrayChunksandArrayChunksMutare absent from this snapshot. Additional coverage includes a native contract proof forChunksExactMutand direct body proofs for theArrayWindowsgetter at widths 1, 2 and 4.Upstream harness coverage
The upstream suite had 72
Iterharness instances. The symbolic suite replaces 28 for()andu8. Of these, 22 exercise 11 methods listed in Challenge 18, includingIter::new. The other six exercise the internal contracts fornext_back_unchecked,post_inc_startandpre_dec_end.The 44 retained regressions cover the original fixed-size
charand(char, u8)cases and the directDefault,Clone,as_sliceandAsRefchecks for()andu8. These runs supplement the symbolic Challenge 18 matrix.Symbolic inputs and loop proofs
SymbolicSlicestarts from initialized backing storage and selects an arbitrary aligned interior start and admissible length. The harnesses exercise empty and interior views, full chunks, partial chunks and remainders where applicable. Non-ZST allocations follow Rust's layout limit and CBMC's representable object-offset range with--object-bits 12. ZST lengths spanusize.fold,for_each,positionandrpositionuse inductive loop contracts. The invariants track the cursor and unconsumed range. The write frames account for the accumulator, callback state and writable elements where applicable. All 56 primary loop harnesses record loop contracts in the native results. Unwinding checks stay enabled and the suite supplies no explicit unwind limits.assumeorany_wheresites in the iterator proof module, each immediately followed by a cover. The proof templates also cover relevant success, exhaustion, boundary and maximal-ZST paths.check_bool_validity_predicatechecks valid and invalid raw encodings.check_observed_invalid_write_is_detectedchecks that writing an invalid byte at the observed index is detected.Verified callees
The
stub_verifieduses below bind to independently proved callee contracts. Kani checks the preconditions at each summarized call.size_hintonChunksMut,ChunksExactMut,RChunksMutandRChunksExactMutnth_backproofscheck_size_hint_contractruns the real method at the same type. It proves equal lower and upper hints. TheChunksExactMutcontract also bounds the lower hint by the slice length.<*mut [[u8; 3]]>::split_at_mut_uncheckedChunksMut,ChunksExactMutandRChunksExactMutcheck_triplet_split_at_mut_unchecked_contractruns the raw split and checks the returned pointers, lengths, writeability and empty write frame.triplet_chunk_regioncheck_triplet_chunk_regionproves same-allocation and access facts for a complete subregion of an accessible input slice.The
size_hintcontracts admit more results than the actual methods return. Mutablenth_backproofs therefore audit checked panics separately from memory-safety properties. In the six CVC5ChunksExactMut::nth_backreplays, the recorded panics are the checked multiply, checked add and split-bound assertion.Proof cost
The four exact
[u8; 3]getter harnesses describe the main view and remainder in byte coordinates.check_triplet_getter_input_domainmaps the original input partition to the same allocation extent, offsets and view lengths. With remaining lengthL, positive chunk sizesand legal indexi, the complete chunk starts ati * sin the forward case andL - i * s - sin the reverse case. The native contract proof runs the original getter and checks its returned pointer and length, same allocation, containment and access obligations.ChunksExactChunksExactMutRChunksExactRChunksExactMutCombining equivalent input guards reduced the total solver time for these four harnesses from 857.36 s to 407.61 s in the same-build comparison. Every getter-owned cover passed in the replay. Each shared getter also reports one unreachable helper cover for a compile-time writable-input branch.
Local results and toolchain
Each ZST layout contributes 115 passing typed harnesses. Each of the five non-ZST layouts contributes 111. The matrix retains results from the compatible Kani baseline and the local tool-fix builds where the source and proof obligations match.
A fresh replay of both submitted fixes on Kani
0aac16efused the original Std source,nightly-2026-10-23, CBMC 6.11.0 and each harness's declared solver. The replay adapts the compiler API and stub-pass registration to that baseline.ChunksExactMut::nth_backpreviously stopped by CBMC status 6[u8; 3]getterssize_hintcontracts, triplet domain proof and subregion contractAll 26 replay harnesses completed within the per-harness timeout. The slowest took 326.66 s. The measured peak process-tree RSS was 2.33 GiB in the serial Linux run.
arith_offsetreturns the original pointer. The fix evaluates both operands in order, including projected reads. Kani #5202The exact PR heads
cb10fb8and55d33ccalso build together on Kani mainc25a57bc. That build produced the expected results for six positive and six expected-failure harnesses across eight tool regression files. It usesnightly-2026-11-18, which stopped the original Std source atcorecompilation on built-ins includingpattern_typeand
view_type. Hosted verification awaits a compatible Kani pin containing the fixes.Limits
TCopytypes exercise distinct layout and validity properties. A proof for arbitrary genericTremains outside this submission. Callback and accumulator proofs likewise use concrete models. Generic-type discussion #734ArrayWindowsexecutes its typed bodies atN = 1, 2, 4. A separate arithmetic proof checks the bounds for arbitrary positive widths.boolobservation checks the modeled representation at an arbitrary selected element. The dedicateduninit-checksandvalid-value-checkspasses are disabled.Resolves #282
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.