Skip to content

Fix HDF5 dataset creation failure when nbodies == 0#212

Merged
The9Cat merged 2 commits intochunkLogicfrom
copilot/sub-pr-210-again
Mar 25, 2026
Merged

Fix HDF5 dataset creation failure when nbodies == 0#212
The9Cat merged 2 commits intochunkLogicfrom
copilot/sub-pr-210-again

Conversation

Copy link

Copilot AI commented Mar 25, 2026

When a node holds zero particles, the chunk clamping logic produces chunk >= 1 against a zero-length dataspace (dims[0] == 0), which violates HDF5's constraint that chunk dimensions must not exceed dataset extent — causing dataset creation to fail. Additionally, std::clamp<int>(0, 1, 0) (lo > hi) is undefined behaviour.

Changes

  • write_H5 (H5:: path, ~line 2645): Guard the chunk/compression property block with h5_particles.size() > 0; an empty dataset is created without chunking or filters.
  • write_HDF5 (HighFive path, ~line 2504): Same guard using nbodies > 0, covering all four dcpl property lists (1-D, 3-D, iattrib, dattrib).
// Before — UB + HDF5 error when nbodies == 0
if (H5compress or H5chunk) { ... std::clamp<int>(chunk, 1, nbodies) ... }

// After — skip filters entirely for empty datasets
if ((H5compress or H5chunk) and nbodies > 0) { ... }

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Copilot AI changed the title [WIP] [WIP] Address feedback on chunk logic error in Component Fix HDF5 dataset creation failure when nbodies == 0 Mar 25, 2026
Copilot AI requested a review from The9Cat March 25, 2026 22:08
@The9Cat The9Cat marked this pull request as ready for review March 25, 2026 22:09
@The9Cat The9Cat merged commit 6411bc5 into chunkLogic Mar 25, 2026
@The9Cat The9Cat deleted the copilot/sub-pr-210-again branch March 25, 2026 22:10
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