H5EA header deserialize computes index block statistics from nsblks before H5EA__hdr_init sets it

Open Beginner friendly
#6,869 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@vchoi-hdfgroup is already working on this.

Since Nov 10, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
backend, data

Research direction

Start in src/H5EAcache.c at H5EA__cache_hdr_deserialize and read how the index block statistics are calculated relative to the later H5EA__hdr_init call. The issue suggests moving the calculation below initialization or deriving nsblks from cparam; verify that the computed size matches the file’s index block and that h5stat reports the expected chunk-index storage.

Written by the indexing model from the issue text.

Description

Where (develop, c9fcf527, 2026-11-06)

H5EA__cache_hdr_deserialize fills the index block statistics before the header is initialised:

  • src/H5EAcache.c:351-357: a fake index block is set up with
    iblock.nsblk_addrs = hdr->nsblks - iblock.nsblks; and
    hdr->stats.computed.index_blk_size = H5EA_IBLOCK_SIZE(&iblock);
  • hdr->nsblks is only set in H5EA__hdr_init (src/H5EAhdr.c:185), which the same function calls later, at
    src/H5EAcache.c:376.
  • The header comes from H5FL_CALLOC (H5EA__hdr_alloc, src/H5EAhdr.c), so hdr->nsblks is 0 when it is
    read, and nsblk_addrs is computed from 0 instead of the real number of super blocks.

Effect

stats.computed.index_blk_size does not match the index block in the file, so the chunk-index storage that
h5stat reports for datasets with an extensible-array index is wrong.

Example with a file from the HDF5 test suite, tools/test/testfiles/h5fc_ext1_f.h5, dataset
/DSET_EA (extensible array header at address 1283, index block at 1355). From the header (h5debug): 4 elements
in the index block, raw element size 8, at least 4 data block pointers per super block, at least 16 elements per
data block. With H5EA_IBLOCK_SIZE and nsblks = 1 + (max_nelmts_bits - log2(16)) the index block is 298 bytes
(prefix 6 + header address 8 + checksum 4 + 4 elements × 8 + 6 data block addresses × 8 + 25 super block
addresses × 8). The statistics are computed with nsblks = 0 instead.

Suggested fix

Compute the index block statistics after H5EA__hdr_init (move the block at H5EAcache.c:342-361 below the
call at :376), or compute nsblks from cparam before using it.

Found while checking the bytes our pure-Go HDF5 implementation (https://github.com/scigolib/hdf5) frees when it
deletes a dataset against h5stat.

Dominant language
C
Stars
1k
Forks
372
Avg merge
2d 15h
Merged PRs (30d)
57

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HDFGroup/hdf5

All issues in HDFGroup/hdf5

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.