fix(reading): probe absolute offsets when searching for the superblock - #185
Open
Blackclaws wants to merge 1 commit into
Open
fix(reading): probe absolute offsets when searching for the superblock#185Blackclaws wants to merge 1 commit into
Blackclaws wants to merge 1 commit into
Conversation
The candidate offsets are 0, 512, 1024, 2048, ..., but the search advanced by a doubling delta from the current position, so it probed 1536, 3584, 7680, ... and only found the superblock for user block sizes of 0 or 512. The bounds check now rejects an offset that cannot hold the 8-byte signature instead of testing the position after a seek that may already be past the end. Closes Apollo3zehn#183 Co-Authored-By: Claude <noreply@anthropic.com>
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.
Fixes #183.
A file written with
UserBlockSizeabove 512 could not be reopened:NativeFile.InternalOpenAsyncadvanced by a doubling delta relative to the current position, so after the 512 candidate it probed 1536, 3584, 7680, … instead of 1024, 2048, 4096, …. h5dump read the same files fine, so only the reader was affected.The search now seeks to each candidate offset absolutely. The bounds check moved with it: it rejects an offset that cannot hold the 8-byte signature, rather than testing the position after a seek that may already be past the end.
Test plan
CanRoundTrip_WithUserBlockinWriting/MiscTests.cswrites and reads back a 4,096-elementintdataset for user block sizes 0, 512, 1024, 2048 and 4096. Before the fix the last three throw "The file is not a valid HDF 5 file."; all five pass after it. Full suite green on net8.0 (no .NET 6 runtime available here, so net6.0 was not exercised).Breaking changes
None.
🤖 Generated with Claude Code