Skip to content

Only take the asarray fast path when blocks are contiguous in the chunk - #724

Merged
FrancescAlted merged 1 commit into
Blosc:mainfrom
jeandet:fix-partitions-behaved-block-contiguity
Sep 24, 2026
Merged

FrancescAlted merged 1 commit into
Blosc:mainfrom
jeandet:fix-partitions-behaved-block-contiguity

Conversation

@jeandet

@jeandet jeandet commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #723.

are_partitions_behaved() now only accepts blocks that are contiguous runs of their chunk, using the same rule as nchunk_fastpath() in b2nd.c. The (shape, chunks) check from #698 is unchanged.

Tests: the two cases from the issue, plus a contiguous layout that must keep the fast path. tests/ndarray passes locally; the only failure is an async test that needs a pytest async plugin I didn't have installed.

🤖 Generated with Claude Code

are_partitions_behaved() accepted blocks that divide the chunk but are
not C-contiguous runs of it, e.g. (32, 1, 16, 32) in (256, 32, 16, 32).
asarray() then wrote C-order chunk data with update_data(), which b2nd
reads back block by block, silently scrambling arrays of 16 MB or more.

Use the same rule as nchunk_fastpath() in C-Blosc2's b2nd.c. Fixes Blosc#723.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@FrancescAlted

Copy link
Copy Markdown
Member

Well seen @jeandet. Thanks! The windows CI failure seems unrelated, so merging.

@FrancescAlted
FrancescAlted merged commit 95830fe into Blosc:main Sep 24, 2026
31 of 36 checks passed
FrancescAlted added a commit that referenced this pull request Sep 24, 2026
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.

asarray silently scrambles data when blocks are not contiguous in the chunk

2 participants