Skip to content

Fix write-path integer overflow in scale-offset filter - #6517

Open
mattjala wants to merge 8 commits into
HDFGroup:developfrom
mattjala:5861_regression_test
Open

Fix write-path integer overflow in scale-offset filter#6517
mattjala wants to merge 8 commits into
HDFGroup:developfrom
mattjala:5861_regression_test

Conversation

@mattjala

@mattjala mattjala commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This started as a regression test for #5864, test_scaleoffset_int_fullprec in test/dsets.c. It writes integer data spanning the entire type range, which forces the filter into its full-precision fallback and exercises the read path that #5864 fixed.

The test ran into a different bug, a signed-integer overflow on the write path. The filter was computing max - min in signed int which, for full-range data, would overflow a signed int.

That subtraction is now performed in unsigned arithmetic instead, which will be safe for any range of input values.

I also added a pre-emptive test for a the analgous full-precision for float datatypes (test_scaleoffset_float_fullprec), though there's no existing problems in that case.

Resolves #5861

@mattjala mattjala added this to the HDF5 2.2.0 milestone Jul 10, 2026
Copilot AI review requested due to automatic review settings July 10, 2026 15:12
@mattjala mattjala added the Component - Testing Code in test or testpar directories, GitHub workflows label Jul 10, 2026
@github-project-automation github-project-automation Bot moved this to To be triaged in HDF5 - TRIAGE & TRACK Jul 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a regression test to ensure the scale-offset filter can round-trip integer chunk data that spans the full precision of the datatype (i.e., stored minbits equals the type’s full bit width), covering the failure mode described in #5861 and fixed in #5864.

Changes:

  • Add a new dedicated test file name entry (scaleoffset_fullprec) to the test file list.
  • Introduce test_scaleoffset_int_fullprec() in test/dsets.c to write, close/reopen, and read back full-range integer data through the scale-offset filter.
  • Register the new test in main() alongside existing scale-offset tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Checklist

This PR touches the following areas. Each needs a sign-off
from its listed owners before merging.

@nbagha1 nbagha1 moved this from To be triaged to On-Deck in HDF5 - TRIAGE & TRACK Jul 10, 2026
@mattjala
mattjala requested review from hyoklee and lrknox as code owners July 10, 2026 16:58
@github-actions
github-actions Bot removed the request for review from lrknox July 10, 2026 16:58
@mattjala mattjala changed the title Add regression test for old scale-offset filter error Fix write-path integer overflow in scale-offset filter Jul 10, 2026
fortnern
fortnern previously approved these changes Jul 10, 2026
@github-actions
github-actions Bot requested a review from jhendersonHDF July 13, 2026 14:16
Comment thread release_docs/CHANGELOG.md Outdated
@github-project-automation github-project-automation Bot moved this from On-Deck to In progress in HDF5 - TRIAGE & TRACK Jul 13, 2026
@mattjala
mattjala requested a review from hyoklee July 14, 2026 14:04
hyoklee
hyoklee previously approved these changes Jul 14, 2026
hyoklee
hyoklee previously approved these changes Jul 20, 2026
@github-actions
github-actions Bot requested review from hyoklee and removed request for jhendersonHDF August 5, 2026 14:42
hyoklee
hyoklee previously approved these changes Aug 6, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component - Testing Code in test or testpar directories, GitHub workflows

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Read errors for some chunks after upgrading to HDF5 1.14.6

5 participants