Skip to content

BUG: Reject transform parameter counts that exceed the metric limit - #6991

Merged
dzenanz merged 1 commit into
InsightSoftwareConsortium:mainfrom
jdotc1:fix/jdotc1-metric-count-overflow-20261022
Oct 27, 2026
Merged

dzenanz merged 1 commit into
InsightSoftwareConsortium:mainfrom
jdotc1:fix/jdotc1-metric-count-overflow-20261022

Conversation

@jdotc1

@jdotc1 jdotc1 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Reject transform parameter counts that exceed the metric return type. Addresses the diagnostic-guard alternative in #6949.

Scope and risk

This rejects unsupported large counts; it does not add a 64-bit metric API or fix every allocation path. The test uses a dummy count and must not allocate a multi-billion-voxel field.

Validation

6 isolated method-body boundary cases compile and pass under GCC with AddressSanitizer/UndefinedBehaviorSanitizer.

Native ITK validation is now available for current head 5cecfc06745aa8c5e6153e3215b1b5323a52d2ee. The Linux ARM64 job compiled with zero compiler errors and warnings and passed all 4,722 configured tests. The actual CountMetric/CountTransform GTest fixture compiled, and both ObjectToObjectMetric.PreservesRepresentableParameterCounts and ObjectToObjectMetric.RejectsParameterCountOverflow passed.

The current-head platform matrix has completed: 18 checks passed, with no pending or failing reported checks. The only skipped job is publish-doxygen-tagfile. Completed checks include Windows C++, macOS and Ubuntu Pixi C++, x86_64 Rosetta, ARM Python, Azure Linux and macOS Python, pre-commit, Doxygen, performance and documentation. The native Linux ARM64 test results above are reused; no tests were repeated for this status update.

Ready for maintainer review. The results establish the native tests on the completed configurations; they do not establish every possible platform-dependent integer-width combination. Maintainer review is needed before merging.

@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Numerics Issues affecting the Numerics module labels Oct 22, 2026
@jdotc1
jdotc1 marked this pull request as ready for review October 23, 2026 04:28
@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds a check in GetNumberOfParameters() that throws before a transform count can overflow the metric’s return type.

  • Metrics reject transform parameter counts they cannot represent.

No actionable issues found. This review checked the code and test setup; it did not run the tests.

Reviews (1) · Last reviewed commit: "COMP: Complete parameter-count metric te..." · Reviewed by Greptile

@hjmjohnson
hjmjohnson force-pushed the fix/jdotc1-metric-count-overflow-20261022 branch from 5cecfc0 to cfd822c Compare October 25, 2026 19:57
ObjectToObjectMetric::GetNumberOfParameters returned the moving
transform's 64-bit IdentifierType count through the metric's unsigned
int NumberOfParametersType, so a dense displacement field with more
than 2^32 - 1 parameters was silently truncated. Callers then sized the
derivative from the truncated count and wrote past its end.

Throw instead when the count does not fit. This makes the overflow a
clear error; widening the metric API remains open.

Addresses InsightSoftwareConsortium#6949.
@hjmjohnson
hjmjohnson force-pushed the fix/jdotc1-metric-count-overflow-20261022 branch from cfd822c to cc15831 Compare October 25, 2026 20:05

@dzenanz dzenanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fix looks good. I have not taken a good look at the test.

@dzenanz
dzenanz merged commit 729d30e into InsightSoftwareConsortium:main Oct 27, 2026
19 checks passed
gdevenyi added a commit to gdevenyi/ITK that referenced this pull request Nov 19, 2026
The v4 metrics returned the transform's 64-bit parameter count through
an unsigned int, so a dense displacement field with more than 2^32 - 1
parameters (about 1.43 billion voxels in 3-D) could not be registered;
the guard from InsightSoftwareConsortium#6991 throws there. CostFunctionTemplate and
ObjectToObjectMetricBaseTemplate now use IdentifierType, as
TransformBase does, and overrides return NumberOfParametersType. The
guard can no longer fire and is removed.

ImageVectorOptimizerParametersHelper also keeps its voxel count as
SizeValueType.

Closes InsightSoftwareConsortium#6949.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Numerics Issues affecting the Numerics module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants