Skip to content

Challenge 10: Kani contracts for String memory safety - #645

Open
sankalpsthakur wants to merge 7 commits into
model-checking:mainfrom
sankalpsthakur:challenge/10-string
Open

Challenge 10: Kani contracts for String memory safety#645
sankalpsthakur wants to merge 7 commits into
model-checking:mainfrom
sankalpsthakur:challenge/10-string

Conversation

@sankalpsthakur

Copy link
Copy Markdown

Summary

Kani safety contracts and proof harnesses for this challenge. Runtime stdlib logic is unchanged; annotations are cfg(kani) / contract attributes.

String allocation/mutation safety contracts.

Validation

  • Local worktree on challenge/10-string
  • Kani CI on this PR is the authoritative run (scripts/run-kani.sh)

Fixes #61

AI/LLM disclosure

  • AI coding tools (including Grok and/or Codex agent-assisted editing) were used to help draft or modify code and this PR description.
  • I reviewed the complete change, understand the reasoning, and take responsibility for the contracts and harnesses.
  • This submission is original work of authorship under the project contributor terms; AI output was not pasted unreviewed.

Kani contracts and harnesses for verify-rust-std challenge.

Fixes rust-lang#61
@sankalpsthakur
sankalpsthakur requested a review from a team as a code owner August 20, 2026 12:08
Drop realloc from insert/insert_str proofs, shrink symbolic bounds so
remove_matches finishes, and run reallocating APIs as body proofs so
Kani does not treat reserve's free as an assigns violation.
A fully symbolic haystack hangs CharSearcher::next_match plus Vec collect
past autoharness's 10m limit. Use a concrete ASCII prefix of symbolic
length 0..=2 so the real ptr::copy / set_len path still runs.
Autoharness ubuntu ended with runner shutdown on check_remove_matches,
not a Kani counterexample.
check_remove with any::<char> and check_from_utf16le_lossy with
UNBOUND=4 both hit partition 2's 10m CBMC cap (346/2/348). Use ASCII
length 1..=2 for remove and a 2-byte slice for lossy decode.
@feliperodri feliperodri added the Challenge Used to tag a challenge label Aug 20, 2026
macos p2 347/1: check_remove failed assigns (ptr::copy as array_replace
vs modifies(self)). macos p1 345/3: remove_matches OOM, retain havoc.
Use body proofs and ASCII length 0..=1/2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Challenge Used to tag a challenge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Challenge 10: Memory safety of String

2 participants