Challenge 29: Kani contracts for Box, convert, and ThinBox - #639
Open
sankalpsthakur wants to merge 3 commits into
Open
Challenge 29: Kani contracts for Box, convert, and ThinBox#639sankalpsthakur wants to merge 3 commits into
sankalpsthakur wants to merge 3 commits into
Conversation
Kani contracts and harnesses for verify-rust-std challenge. Fixes rust-lang#526
Place #[cfg(kani)] use core::kani with neighboring core uses and group
use core::{fmt, kani} so the upstream_test format check passes.
Autoharness macos/ubuntu failed on check_downcast_any, check_downcast_error, and check_from_slice_clone (CBMC timeout). Match the passing sibling proofs: is_ok/is_err only, fixed-length Clone from_slice with unwind(3). No runtime stdlib change. Fixes rust-lang#526
Author
|
Ready for committee FCFS review of Challenge 29 (in-window, end 2026-12-31). Head
Tracking Fixes #526. No second solution PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Kani safety contracts and proof harnesses for Challenge 29 (Box / convert / ThinBox). Runtime stdlib logic is unchanged; annotations are
cfg(kani)plus the repo-standard tool-agnosticsafety::{requires, ensures}attributes (notcfg_attr(kani, kani::requires)).In-window ticket (end 2026-12-31, $15,000 USD). Tracking #526.
Success criteria mapping
Required unsafe functions (contracts + verified harnesses):
Box<MaybeUninit<T>, A>::assume_initand slice form —#[requires]/#[ensures]+proof_for_contractBox::from_raw,from_non_null,from_raw_in,from_non_null_in— same, including sized + slice instantiations<dyn Error>::downcast_unchecked(×3). That API does not exist in this tree (impl dyn Erroronly has safedowncast). The three real methods areBox<dyn Any (+ Send) (+ Sync), A>::downcast_unchecked. Those three carrysafetycontracts; harnesses execute the bodies underis::<T>(). Kani cannotproof_for_contractthe trait-object generic methods (resolver lists the three impls and rejects angle-bracket paths) — same limitation as other Challenge 29 submissions.Safe wrappers (≥75% of 46): 45/46 covered (the listed
TryFrom<Box<T>>impl does not exist;TryFrom<Vec<T>>is extra). Includes ThinBoxDeref/DerefMut/Drop/meta/with_headerandWithHeader::{new, try_new, new_unsize_zst, header},from_slice(TrivialClone + Clone), Error/Any downcast ok/err paths,into_pinwith!Unpin.UBs: dangling/misaligned access, intrinsic UB, mutating immutable bytes, invalid values — via Kani's default checks on the real std bodies. No
cfg(not(kani))body swap.Validation
challenge/29-boxed, head5d8f0ee99218643bc7eb62fe39aa70b6c43508cbscripts/run-kani.shComplete - 1444 successfully verified harnesses, 0 failures(job 96454587856, 56 min). Ubuntu autoharness SUCCESS:Complete - 1445 successfully verified harnesses, 0 failures(job 96454587592, 1h12m). Prior SHAb389760had 3 convert CBMC timeouts; slim on this SHA cleared them on both OS..upstream_testubuntu+macos, Flux, GOTO, VeriFast, simd models, build: SUCCESSFixes #526
AI/LLM disclosure