BlockLayout2D: copy caller-supplied origins

An int64 C-contiguous origins array was kept by reference (and frozen in
the caller's hands), so mutating it later changed layout.origins and
block_cell without changing owner/halos. Copy before marking read-only;
regression checks origins, owner and block_cell invariance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-10-16 03:15:37 +00:00
co-authored by Claude Opus 5.5
parent fa7fd9097a
commit aecee19c19
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -144,7 +144,7 @@ class BlockLayout2D:
jy, jx = np.divmod(np.arange(nby * nbx), nbx)
origins = np.stack([jy * by, jx * bx], axis=1)
selected = _selected_blocks(origins, ny, nx, by, bx)
origins = np.asarray(origins, dtype=np.int64).reshape(-1, 2)
origins = np.array(origins, dtype=np.int64).reshape(-1, 2) # own copy, never caller storage
if (len(origins) + 1) * NQ * cells > np.iinfo(np.int64).max // 2:
raise ValueError("blocked storage exceeds 64-bit indexing")