Skip to content

Fix out-of-bounds prefetch pointer arithmetic - #1

Open
russellromney wants to merge 1 commit into
orlp:mainfrom
russellromney:agent/fix-mincdc-prefetch-ub
Open

Fix out-of-bounds prefetch pointer arithmetic#1
russellromney wants to merge 1 commit into
orlp:mainfrom
russellromney:agent/fix-mincdc-prefetch-ub

Conversation

@russellromney

@russellromney russellromney commented Jul 12, 2026

Copy link
Copy Markdown

What changed

Use wrapping_add when computing the three x86 SIMD prefetch addresses.

Why

The 16 KiB prefetch distance routinely places the address beyond the input allocation. The prefetch instruction itself is non-faulting, but Rust's ptr::add requires the computed pointer to remain within or one past the allocation even when it is not dereferenced. wrapping_add preserves the intended machine behavior without creating an invalid in-bounds-derived pointer.

Validation

  • cargo fmt --all -- --check
  • cargo test --target x86_64-apple-darwin prefetch_pointer_may_wrap_beyond_a_short_slice
  • existing argmin differential test

The regression helper/test gives provenance-aware tools such as Miri a direct path that computes a deliberately far-out prefetch pointer from a one-byte slice without invoking a SIMD prefetch instruction.

@russellromney
russellromney force-pushed the agent/fix-mincdc-prefetch-ub branch from b07369f to 63ff49d Compare July 12, 2026 08:02
@russellromney
russellromney marked this pull request as ready for review July 13, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant