Skip to content

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

Closed
sankalpsthakur wants to merge 1 commit into
model-checking:mainfrom
sankalpsthakur:challenge/10-string
Closed

Challenge 10: Kani contracts for String memory safety#645
sankalpsthakur wants to merge 1 commit 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.

@sankalpsthakur
sankalpsthakur requested a review from a team as a code owner August 20, 2026 12:08
@feliperodri feliperodri added the Challenge Used to tag a challenge label Aug 20, 2026
@sankalpsthakur

Copy link
Copy Markdown
Author

both ubuntu jobs die with a runner shutdown signal shortly after string::verify::check_from_utf16le_lossy starts, while the 3-thread macos jobs finish that same harness in 238s, so it was peaking the 16 gb runner's memory rather than failing a check. switched it to kissat, the same remedy core::ptr uses for check_align_offset_5; state space and check count are unchanged.

Add safety contracts and proof harnesses covering String allocation and
mutation. Runtime stdlib logic is unchanged: everything added here is
either a contract attribute or lives behind cfg(kani).

check_from_utf16le_lossy passes the whole 2-byte buffer instead of a
symbolic sub-slice. On a little-endian target it is the only one of the
four UTF-16 harnesses that keeps the align_to::<u16> arms of
from_utf16le_lossy live, and any_slice_of_array picks a symbolic start
as well as a symbolic end, which left the slice's base pointer alignment
symbolic on top of that. Both bytes are still symbolic; only the slice
bounds are now fixed.

This also drops the earlier solver(kissat) selection. kissat did not
stop the ubuntu runner being reclaimed mid-solve, and it made the
harness slower on macOS, where it then ran past the 10m autoharness
timeout.

Fixes rust-lang#61
@sankalpsthakur

Copy link
Copy Markdown
Author

dropped solver(kissat); ubuntu was still getting reclaimed with it in place, and it pushed the macos autoharness run past the 10m cap. check_from_utf16le_lossy now takes the whole 2-byte buffer rather than a symbolic sub-slice, so the bytes stay symbolic but the base pointer alignment feeding align_to:: doesn't.

@sankalpsthakur

Copy link
Copy Markdown
Author

Withdrawing this; no maintainer signal and we are cutting the queue.

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