Fix Global Heap over-read on sub-header trailing padding - #261
Merged
Conversation
`GlobalHeap.objects` looped `while offset < len(self.heap_data)`, so it entered the loop with fewer than a full 16-byte `GLOBAL_HEAP_OBJECT` header remaining and then over-read the buffer. A collection's trailing free space is marked by an object with index 0, but libhdf5 writes that marker only when at least one 16-byte object header fits. When the remainder is smaller it is undefined padding. Add `tests/test_global_heap.py`, which builds raw GCOL collections in memory and reads them through `GlobalHeap`, deterministically reproducing the crash (a <16-byte trailing pad) and covering the index-0 terminator and exactly-full cases. Fixes NCAS-CMS#259.
davidhassell
approved these changes
Sep 1, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #261 +/- ##
==========================================
+ Coverage 78.48% 78.62% +0.13%
==========================================
Files 15 15
Lines 3416 3485 +69
Branches 546 555 +9
==========================================
+ Hits 2681 2740 +59
- Misses 593 602 +9
- Partials 142 143 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Thanks @davidhassell @bnlawrence! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
GlobalHeap.objectsloopedwhile offset < len(self.heap_data), so it entered the loop with fewer than a full 16-byteGLOBAL_HEAP_OBJECTheader remaining and then over-read the buffer. A collection's trailing free space is marked by an object with index 0, but libhdf5 writes that marker only when at least one 16-byte object header fits. When the remainder is smaller it is undefined padding.Add
tests/test_global_heap.py, which builds raw GCOL collections in memory and reads them throughGlobalHeap, deterministically reproducing the crash (a <16-byte trailing pad) and covering the index-0 terminator and exactly-full cases.Closes #259.
Checklist