Skip to content

Fix views of arrays that do not start at the beginning of their memory - #61

Merged
lkdvos merged 3 commits into
mainfrom
ld-array-offset
Oct 14, 2026
Merged

lkdvos merged 3 commits into
mainfrom
ld-array-offset

Conversation

@lkdvos

@lkdvos lkdvos commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

On Julia ≥ 1.11, an Array parent is normalized to its Memory (A.ref.mem), which drops the offset of A.ref into that memory. Arrays that do not start at the beginning of their memory, e.g. after popfirst! or deleteat! at the front, or reshapes of those, therefore give views that are shifted:

v = collect(1.0:5.0); popfirst!(v)
StridedView(v)  # [1.0, 2.0, 3.0, 4.0] instead of [2.0, 3.0, 4.0, 5.0]

This also shifts reads and writes through Strided.jl and pointers handed to BLAS.

The fix lets _normalizeparent(A, offset) return the normalized parent together with the matching offset, so the two cannot get out of sync (the PtrArrays extension is updated accordingly). For an Array this adds the memory offset of A.ref. There are tests for reading, slicing, writing and pointer. Julia 1.10 normalizes via reshape, which keeps the offset, and was not affected.

This leaves the version alone, to be released after #60.

🤖 Generated with Claude Code

lkdvos and others added 3 commits October 13, 2026 12:35
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lkdvos
lkdvos requested review from Jutho and kshyatt October 13, 2026 19:13
@lkdvos
lkdvos enabled auto-merge (squash) October 14, 2026 00:19
@lkdvos
lkdvos merged commit 8ec962b into main Oct 14, 2026
9 of 13 checks passed
@lkdvos
lkdvos deleted the ld-array-offset branch October 14, 2026 08:00
@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ext/StridedViewsPtrArraysExt.jl 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/auxiliary.jl 72.46% <100.00%> (+1.44%) ⬆️
src/stridedview.jl 29.94% <100.00%> (ø)
ext/StridedViewsPtrArraysExt.jl 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants