BUG: Validate TileImageFilter Layout has no zero before the last axis#6630
Merged
hjmjohnson merged 1 commit intoJul 14, 2026
Conversation
A zero in any non-last Layout entry makes GenerateOutputInformation divide by zero or index an empty vector. Reject it in VerifyPreconditions before the output region is computed. Addresses item B87 of InsightSoftwareConsortium#6575.
Contributor
|
| Filename | Overview |
|---|---|
| Modules/Filtering/ImageGrid/include/itkTileImageFilter.h | Declares the new precondition hook for layout validation. |
| Modules/Filtering/ImageGrid/include/itkTileImageFilter.hxx | Rejects zero layout entries in non-last dimensions before output generation. |
| Modules/Filtering/ImageGrid/test/itkTileImageFilterGTest.cxx | Adds tests for invalid zero-layout configurations. |
Reviews (2): Last reviewed commit: "BUG: Validate Layout has no zero before ..." | Re-trigger Greptile
blowekamp
self-requested a review
July 14, 2026 14:25
blowekamp
approved these changes
Jul 14, 2026
hjmjohnson
marked this pull request as draft
July 14, 2026 14:58
hjmjohnson
approved these changes
Jul 14, 2026
hjmjohnson
marked this pull request as ready for review
July 14, 2026 15:01
dzenanz
approved these changes
Jul 14, 2026
hjmjohnson
merged commit Jul 14, 2026
ab57477
into
InsightSoftwareConsortium:main
20 of 22 checks passed
hjmjohnson
added a commit
to hjmjohnson/ITK
that referenced
this pull request
Jul 15, 2026
The product of the non-last-axis Layout counts was accumulated in a
32-bit int before being used as a division-by-zero-prone divisor to
auto-size the last axis. For a large Layout (e.g. {65536, 65536, 0}),
the product wraps in 32-bit arithmetic and can land on exactly 0,
turning the division into a SIGFPE on architectures whose idiv traps.
Widen the accumulator to SizeValueType and reject the pathological
case where it's still zero.
Forward-fix for the review finding on PR InsightSoftwareConsortium#6630 (merged).
hjmjohnson
added a commit
to hjmjohnson/ITK
that referenced
this pull request
Jul 15, 2026
The product of the non-last-axis Layout counts was accumulated in a
32-bit int before being used as a division-by-zero-prone divisor to
auto-size the last axis. For a large Layout (e.g. {65536, 65536, 0}),
the product wraps in 32-bit arithmetic and can land on exactly 0,
turning the division into a SIGFPE on architectures whose idiv traps.
Widen the accumulator to SizeValueType and reject the pathological
case where it's still zero.
Forward-fix for the review finding on PR InsightSoftwareConsortium#6630 (merged).
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.
TileImageFilternever validatesLayout: a 0 in any axis but the last indexes an emptystd::vectorand runs a loop of about 2^32 iterations, and the constructor's own all-zero default divides by zero. Addresses B87 of #6575.Root cause and fix
Only the last axis of
Layoutmay be 0 (meaning "as many tiles as needed"); a 0 anywhere else is meaningless, and the tile-index arithmetic inGenerateData()has no defense against it. Rather than guarding each use site,VerifyPreconditions()now rejects a zero in any non-last axis, soGenerateData()cannot be reached with an unusable layout.Local validation
Two cases added to
itkTileImageFilterGTest.cxx:RejectsZeroInNonLastLayoutAxis— fail-before: no exception (then UB). Pass-after: throws.RejectsDefaultZeroLayout— same, for the constructor default.ctest -L ImageGrid: 69/69 pass, unchanged.AI assistance