fix(format): read layout v4 chunk dimensions of any width from 1 to 8 bytes
A version-4 layout stores every chunk dimension in the fewest bytes that hold the largest one (H5D__chunk_set_sizes: (log2(dim) + 8) / 8), so a chunk dimension of 65 536 to 16 777 215 takes 3 bytes. Only widths 1, 2, 4 and 8 were decoded; an h5py file with chunks=(70000,) and libver='latest' failed with UnexpectedEof. Widths 1-8 are decoded now; 0 and more than 8 are refused with libhdf5's "encoded chunk dimension size is too large", and a dimension past u32 is refused, not truncated. The review asked for libhdf5's check that the stored width matches the one computed from the dimensions. HDF5 2.0.0 (h5py 3.16) refuses any mismatch, but HDFGroup/hdf5@e124c36 ("Allow reading of files with chunk dimensions encoded using more bytes than necessary", 2026-06-05) relaxed it to refusing only a width too small for the dimensions, which cannot happen once the dimensions have been decoded from that width. Follow current libhdf5: a wider-than-needed encoding is read. clawhdf5's own writer produces such layouts (the next commit fixes that). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -359,6 +359,16 @@
|
||||
to each check. **Breaking (format crate):** `FormatError` gained
|
||||
`InvalidObjectHeader`, `InvalidDatatype`, `InvalidChunkDimensions` and
|
||||
`TruncatedFile`; an exhaustive `match` on it needs the new arms.
|
||||
- **Chunked datasets whose chunk dimensions take 3, 5, 6 or 7 bytes did not
|
||||
open.** A version-4 layout (`libver="latest"`) stores each chunk dimension
|
||||
in the fewest bytes that hold the largest one, so a chunk dimension from
|
||||
65 536 to 16 777 215 (e.g. h5py `chunks=(70000,)`) takes 3 bytes; only 1, 2,
|
||||
4 and 8 were read, and the rest failed with `UnexpectedEof`. Widths 1-8 are
|
||||
read now, and 0 or more than 8 is refused as libhdf5 refuses it. A width
|
||||
larger than needed is accepted: HDF5 2.0.0 refuses one ("stored chunk
|
||||
dimension encoding length does not match"), but libhdf5 since
|
||||
HDFGroup/hdf5@e124c36 (2026-06-05) reads it, and clawhdf5 itself wrote such
|
||||
layouts.
|
||||
- `clawhdf5-format` VDS: variable-length and reference data from a source in
|
||||
another file is refused. Those elements are global-heap IDs and object
|
||||
addresses in the source file; copied into the virtual dataset they would
|
||||
|
||||
Reference in New Issue
Block a user