Skip to content

BUG: C15: Unsafe numeric conversion and range computation in 39 filters #1874

Open

Description

@imikejackson

Progress and batch plan (4 November 2026)

This is a multi-batch issue. Keep it open until the remaining findings are addressed and the changes are merged. The checklist below records the original 21 October 2026 audit; unchecked entries are not a claim that the listed work is absent from every branch or draft PR.

ImageProcessing batch: implemented in draft PRs

The ImageProcessing batch covers 18 filters and 19 findings. simplnx #1888 contains the public implementation, documentation, and example migrations. SimplnxOoc #11 contains its disk-backed coverage. DREAM3DNX #1233 contains the associated Windows packaging change. These PRs are drafts and have not merged. Their descriptions record foundation dependencies, merge order, and pending package checks.

Histogram batch: implemented locally; PRs pending

Compute Array Histogram and Compute Array Histogram by Feature cover 2 filters and 5 findings. Their coordinated changes are committed on local branches named fix/unsafe-numeric-conversions-remaining-1874 in simplnx, SimplnxOoc, and DREAM3DNX. These histogram branches have not been pushed and have no PRs yet. The two backend branches were based on the ImageProcessing batch because they need its existing changes; the application branch was based on its OOC foundation. Confirm current ancestry and integration requirements again before publication.

The approved histogram contract includes automatic ranges with the observed maximum included, upper-exclusive custom ranges, exact UInt64 counts, Float64 reported boundaries with precision diagnostics, preserved modal and tie behavior, Error by default for nonfinite input with an optional Warn and Skip mode, and a bin-zero constant-data state. Optional bin numbers preserve exact source membership when reported Float64 boundaries cannot. Charting and visualization report sampling, rebinning, and precision limits. Detailed chart CSV data is optional and uses a separate companion file. The application branch also contains a separately committed spreadsheet integer-display fix.

Windows Release and targeted Debug tests cover the local changes, including disk-backed storage and consumer paths. The user completed manual checks before the rebase. A full before/after comparison of affected packaged bookmarks was also performed before the rebase, but has not been repeated on the rebased revisions. One scientific-volume bookmark produced unreadable TIFFs in both compared versions; it is an inherited export blocker, not a passing image-output comparison. The blocker is tracked separately in TIFF export issue #1914. Do not treat pre-rebase package evidence as a post-rebase pass.

Remaining C15 work: 19 filters, 22 findings

After the two batches above, six groups remain. Each group gets its own task branch and PR batch. When a group needs changes in multiple repositories, use the same task branch name in each repository and coordinate the repository-specific PRs. Check actual dependencies and current parent commits before choosing the base; do not silently include another unfinished group.

  1. Statistics and bounds — 3 filters, 5 findings: ComputeArrayStatisticsFilter (Feature/DataStructure #2, Initial Filter and Parameter porting #5), ComputeNeighborListStatisticsFilter (feature/infrastructure #1), and ComputeBoundingBoxStatsFilter (Feature/montage #3, Initial Filter and Parameter porting #5). This is the suggested next group. Recheck each original finding against current code and agree on behavior before implementation.
  2. General arithmetic — 3 filters, 3 findings.
  3. Color conversions and maps — 2 filters, 2 findings.
  4. Geometry and dimensions — 4 filters, 5 findings.
  5. Large indices and counts — 5 filters, 5 findings.
  6. Export workload and bounds — 2 filters, 2 findings.

The original checklist below names the filters and source observations. Recheck current code and open PRs before selecting a fix. For each batch, verify affected producer-to-consumer pipelines and packaged bookmarks, make any necessary migrations part of the shipped update, and record actual execution and output checks separately from source inspection. The HTML review companion records the ImageProcessing decisions; check its publication date before relying on it for the newer histogram batch.


Summary

Many filters convert numbers in an unsafe way, or compute a data range in an unsafe way. The result is undefined behavior, wrong output, or an out-of-bounds index. The output can also be different on x86 and ARM. Four sub-patterns occur:

  • (cast) A floating-point result is converted to an integer output with a plain static_cast, with no clamp and no NaN test.
  • (overflow) Index, product, sum, difference or median arithmetic is done in int32 or in the element type T, so it overflows.
  • (truncation) A float division is truncated to an index or a dimension, so a value like 44.999996 becomes 44.
  • (range) An automatic minimum/maximum range is seeded from the first value (a NaN there poisons the range), from numeric_limits<T>::min() (which is FLT_MIN for floats), from fixed constants, or is extended with max + 1.

As of develop 419f9db (2026-10-21), there are 46 open findings in 39 filters: 4 CRASH, 39 WRONG_DATA, 3 MINOR. All findings are candidates. They were found and re-checked by reading the code. Nobody ran the code to confirm them.

Mechanism

(cast) In C++, the conversion of a NaN, an infinity, or an out-of-range floating-point value to an integer type is undefined behavior. Many unary ImageProcessing filters are templated on the output type U, and U is the same as the input type. These filters accept integer input (GetScalarNumericTypes), so the default settings reach the unsafe path. Example from AcosImageFilter: a uint8 value of 2 gives acos(2) = NaN, which is then cast to uint8:

auto makeMapOp() const
{
return [](T value) -> U { return static_cast<U>(std::acos(static_cast<double>(value))); };
}

  auto makeMapOp() const
  {
    return [](T value) -> U { return static_cast<U>(std::acos(static_cast<double>(value))); };
  }

The safe form already exists on develop. ImageProcessing::detail::SaturateCastFromDouble<U> (src/simplnx/Utilities/ImageProcessing/ImageProcessingFilterUtilities.hpp, line 200) maps NaN to 0 and clamps to the range of U. SigmoidImageFilter, RescaleIntensityImageFilter, IntensityWindowingImageFilter and InvertIntensityImageFilter use it:

return [a, b, oMax, oMin](T value) -> U {
// Output bounds are Float64 and can exceed a narrow output type; saturate-cast to U to avoid UB.
const double d = static_cast<double>(value);
return ImageProcessing::detail::SaturateCastFromDouble<U>((oMax - oMin) * (1.0 / (1.0 + std::exp(-(d - b) / a))) + oMin);
};

    return [a, b, oMax, oMin](T value) -> U {
      // Output bounds are Float64 and can exceed a narrow output type; saturate-cast to U to avoid UB.
      const double d = static_cast<double>(value);
      return ImageProcessing::detail::SaturateCastFromDouble<U>((oMax - oMin) * (1.0 / (1.0 + std::exp(-(d - b) / a))) + oMin);
    };

The histogram bin helper HistogramUtilities::serial::CalculateBin has the same problem. It returns the bin index in the input type, so a negative or large bin wraps for 8-bit and 16-bit input.

(overflow) Arithmetic is written in the data type (T, int, int32) instead of a wide type. Examples: (a + b) * 0.5 for a median in int32, (value - min) / (max - min) in int32, a flat GBCD index in int32, and a uint8 sum. A comparison of int32 with usize converts -1 to SIZE_MAX. Much of this code comes from legacy code that targeted smaller data.

(truncation) An integer quantity is computed through float arithmetic and then truncated: static_cast<size_t>(a / b) or idx * (1.0 / dimX). For example, 49 * (1.0 / 49) is 0.9999999999999999, which truncates to 0.

(range) Each filter writes its own minimum/maximum scan. std::min(NaN, v) returns NaN, so a NaN at index 0 keeps the range NaN. range.second += T(1) wraps for uint8 255, and has no effect for large floats.

At the time of the 21 October 2026 audit, no finding of this class was fixed on develop or in an open pull request.

Rule

No rule is decided for this class yet. The fix patterns below are proposals.

  • (cast) Send every float-to-integer output write through one saturating cast (ImageProcessing::detail::SaturateCastFromDouble<U>: NaN gives 0, other values are clamped to [lowest, max]).
  • (overflow) Do index arithmetic in usize or int64. Accumulate and subtract in float64, int64 or uint64. Convert both median operands to float64 before you add them. Compare a signed value with an unsigned value only after a sign check. Print sizes with a 64-bit format.
  • (truncation) Use integer division to split a flat index into x, y, z. Round (or add a small epsilon in float64) before you convert a computed dimension to an integer.
  • (range) Seed the minimum with +inf or numeric_limits<T>::max(), and the maximum with numeric_limits<T>::lowest(). Skip non-finite values. Keep the range in float64, and include the maximum in the last bin instead of max + 1.

Decision needed:

  1. Math filters with integer input (Acos, Asin, Exp, ExpNegative, Log, Log10, Sqrt, Square, Tan):
    • (a) keep the output type equal to the input type and use SaturateCastFromDouble<U>, or
    • (b) force a float output type when the input is an integer type. This changes the output type, so pipelines and exemplars can change.
  2. Range computation:
    • (a) make one NaN-aware minimum/maximum helper and use it in every filter of the (range) sub-pattern. One candidate is to make ComputeArrayMinMax (src/simplnx/Utilities/ImageProcessing/StreamingStatistics.hpp) NaN-aware and reuse it. It is not NaN-aware on develop.
    • (b) fix each scan where it is.
  3. HConvexImageFilter and HMinimaImageFilter with a fractional Height on integer input: (a) convert Height to T once, as ITK does, or (b) reject a fractional Height for integer input in preflight.

How to fix

  1. Write the failing test first (see "How to test").
  2. Fix shared code once. Several findings share one site:
    • src/simplnx/Utilities/HistogramUtilities.hpp CalculateBin (ComputeArrayHistogramFilter, ComputeArrayHistogramByFeatureFilter): return int64, compute in float64, and range-check the bin before use.
    • src/simplnx/Utilities/ImageProcessing/ImageProcessingFilterUtilities.hpp line 2102 (HConvexImageFilter, HMinimaImageFilter).
    • src/simplnx/Utilities/Math/StatisticsCalculations.hpp line 126 (ComputeNeighborListStatisticsFilter, and the median in ComputeArrayStatisticsFilter).
    • src/simplnx/Utilities/ImageProcessing/FiniteDifferenceEngine.hpp lines 1510, 1694, 2165 and 2307 (CurvatureFlowImageFilter).
  3. Then add one test for each filter that uses the shared code, in the commit for that filter.
  4. Fix both the Direct and the Scanline algorithm when a filter has both. Several findings name the same code in both paths.
  5. When a value is invalid and you cannot clamp it in a meaningful way, return an error. Put the check in preflight if it uses only parameter values (for example Label Offset + Number Of Thresholds <= 255). Put it in execute if it needs DataArray values.
  6. New error codes must use the range of that filter. Filter error codes are more negative than -10000, and each filter uses one range of 100 codes (first code -47500 gives -47500..-47599). Check that the code is unique with git grep -nE -- "-NNNN([^0-9]|$)". Do not use \b, because git grep -E ignores it. Also check the open pull request branches.
  7. Remove any execute-time check that a new preflight check makes unreachable.

How to test

  • Write a unit test that fails on develop before you change the code. Use the trigger in the checklist line as the input.
  • (cast): use an integer input with a value that gives NaN, an infinity, or an out-of-range result (for example uint8 2 for Acos, uint8 16 for Square). Assert the saturated value (NaN gives 0; out-of-range gives the type minimum or maximum). Undefined behavior can pass by chance on one platform, so assert the exact expected value. Also run the test with UndefinedBehaviorSanitizer (-fsanitize=float-cast-overflow) if you can.
  • (overflow): use values near the type limits (for example int32 {2000000000, 2000000000} for a median). For index overflow on very large data (M3CSurfaceMeshingFilter, ReadStlFileFilter, WriteVtkRectilinearGridFilter, ConnectedComponentImageFilter), a full-size test is not practical. Test the index function directly, or write in the pull request why no test is possible.
  • (truncation): use a dimension that gives a truncation error (for example X dimension 49 for ComputeEuclideanDistMapFilter, Exact Dimensions X = 45 for ResampleImageGeomFilter).
  • (range): put a NaN at tuple 0 and at a later tuple. The result must be the same for both inputs.
  • Compute each expected value independently (by hand or with a separate formula), not from the output of the code under test.
  • If a filter has Direct and Scanline algorithms, run both through the existing algorithm-selection test scope.
  • If a fix changes an existing exemplar result, check the new value against an independent expected result before you update the exemplar. Write the change in the pull request.
  • If you cannot reproduce a finding, write this with the reason in the pull request and on this issue. Do not force a fix.

Conventions

  • Make one pull request for the whole class, with one commit for each filter.
  • Start each commit message with BUG: and add a Signed-off-by line. Do not add AI attribution.
  • Start each fix with a unit test that fails on develop.
  • Value checks need an independent expected result (oracle), not the output of the code under test.
  • Run ctest serially. Never use -j, because the tests depend on each other.
  • Format with clang-format 19.1.1 and the repository .clang-format.
  • Do not add sentences about input requirements to the filter documentation. The generated parameter table documents them.
  • If a fix touches a filter that has a V&V report (src/Plugins/<Plugin>/vv/<Filter>.md), update every file of its V&V package (report, deviations, provenance, test tables). V&V documents reference DREAM3D 6.5.171 only.
  • Rebase on develop. Do not merge develop into the branch.

Checklist

  • CRASH · ComputeGBCDFilter · ComputeGBCD.cpp:499 — (overflow) totalGBCDBins (line 389) and phase * totalGBCDBins are int32; GBCD Spacing = 2.0 with Phase 2 gives 2.95e9, so the index wraps and writes out of bounds. ComputeGBCDFilter#4

  • CRASH · M3CSurfaceMeshingFilter · M3CSurfaceMeshing.cpp:1799 — (overflow) int new_node0 (also lines 1987, 2104, 2359) and int tsq (1644, 1702, 2705, 2733) hold int64 node ids; ids >= 2^31 (about 700^3 cells) become negative and index out of bounds. M3CSurfaceMeshingFilter#3

  • CRASH · ReadStlFileFilter · ReadStlFile.cpp:160 — (overflow) The triangle loop variable is int32_t (line 99); 3 * (3 * t + 2) + 2 overflows for 238,609,295 or more triangles and writes out of bounds. ReadStlFileFilter#2

  • CRASH · WriteOnScaleTableFileFilter · WriteOnScaleTableFile.cpp:494 — (overflow) grainId <= maxGrainId never ends for a uint64 Feature Id of UINT64_MAX; a sparse large id (2,000,000,000) writes billions of lines with no cancel check. WriteOnScaleTableFileFilter#2

  • WRONG_DATA · AcosImageFilter · AcosImageFilter.cpp:23 — (cast) A uint8 input value >= 2 gives acos = NaN, which is cast to uint8 with no saturation. AcosImageFilter#1

  • WRONG_DATA · ArrayCalculatorFilter · ArrayCalculator.cpp:300 — (cast) With an integer Output Numeric Type, sqrt(-1), 1/0 or A * 1000 into uint8 is cast with a plain static_cast (also line 326). ArrayCalculatorFilter#4

  • WRONG_DATA · AsinImageFilter · AsinImageFilter.cpp:23 — (cast) An integer input value with |v| >= 2 gives asin = NaN, which is cast to the integer output type. AsinImageFilter#1

  • WRONG_DATA · CombineAttributeArraysFilter · CombineAttributeArrays.cpp:152 — (overflow) With Normalize Data = true, (value - min) / (max - min) is done in the input type; int32 {-2e9, 0, 2e9} overflows and gives values outside [0, 1]. CombineAttributeArraysFilter#1

  • WRONG_DATA · ComputeArrayHistogramByFeatureFilter · HistogramUtilities.hpp:89 — (cast) CalculateBin returns the bin in the input type; a uint8 value 100 with custom Min 200 gives a negative bin that wraps, and Direct counts it because it does not call isInHistogramRange as Scanline does. ComputeArrayHistogramByFeatureFilter#4

  • WRONG_DATA · ComputeArrayHistogramByFeatureFilter · ComputeArrayHistogramByFeature.cpp:234 — (range) Full-range mode uses max + 1; for float32 max >= 2^24 this equals max, so the maximum value is counted as overflow. Same in Scanline. ComputeArrayHistogramByFeatureFilter#7

  • WRONG_DATA · ComputeArrayHistogramFilter · ComputeArrayHistogram.cpp:685 — (range) range.second += T(1) wraps uint8 255 (int8 127, uint16 65535) to the minimum, so Bin Ranges and Counts are wrong for any 8-bit image that contains 255. ComputeArrayHistogramFilter#1

  • WRONG_DATA · ComputeArrayHistogramFilter · HistogramUtilities.hpp:89 — (cast) CalculateBin casts the bin to the input type; uint8 with 1000 bins (value 9 gives bin 900), or a value below the custom Min, is out of range for uint8 and is counted in the wrong bin. ComputeArrayHistogramFilter#2

  • WRONG_DATA · ComputeArrayHistogramFilter · ComputeArrayHistogram.cpp:667 — (range) The range is seeded from the first value; float32 {NaN, 1, 2, 3} gives NaN bins and zero counts, but {1, NaN, 2, 3} does not. ComputeArrayHistogramFilter#4

  • WRONG_DATA · ComputeArrayStatisticsFilter · HistogramUtilities.hpp:394 — (range) The maximum is seeded with numeric_limits<T>::min() (FLT_MIN); per-feature float values {-5, -3} with Feature Range Type = None give Maximum = 1.17e-38. ComputeArrayStatisticsFilter#2

  • WRONG_DATA · ComputeArrayStatisticsFilter · ComputeArrayStatistics.cpp:2315 — (overflow) The median adds the two middle values in T; int32 {2000000000, 2000000000} overflows and gives a negative median. ComputeArrayStatisticsFilter#5

  • WRONG_DATA · ComputeBoundingBoxStatsFilter · ComputeBoundingBoxStatsDirect.cpp:101 — (truncation) floor((v - origin) / spacing) in float32 (also line 81 and Scanline) is off by one for bounds such as 2.1 at spacing 0.1, so cells are dropped or added. ComputeBoundingBoxStatsFilter#3

  • WRONG_DATA · ComputeBoundingBoxStatsFilter · ComputeBoundingBoxStatsDirect.cpp:582 — (overflow) The sum is accumulated in T; two uint8 cells of 200 give 144, so Sum, Mean and StdDev are wrong. Same in Direct 674/791 and Scanline 587/643. ComputeBoundingBoxStatsFilter#5

  • WRONG_DATA · ComputeDifferencesMapFilter · ComputeDifferencesMap.cpp:78 — (overflow) The absolute difference is computed in the signed input type; int8 100 and -100 give -56. The preflight warnings cover only unsigned types. ComputeDifferencesMapFilter#1

  • WRONG_DATA · ComputeEuclideanDistMapFilter · ComputeEuclideanDistMap.cpp:345 — (truncation) int64(idx * (1.0 / dimX)) gives 0 for 49 * (1.0 / 49), so y or z of the seed is one too low for X dimensions such as 49 or 98. Same in Scanline. ComputeEuclideanDistMapFilter#1

  • WRONG_DATA · ComputeNeighborListStatisticsFilter · StatisticsCalculations.hpp:126 — (overflow) The median adds the two middle values in T; a NeighborList list {2000000000, 2100000000} overflows. ComputeNeighborListStatisticsFilter#1

  • WRONG_DATA · ConnectedComponentImageFilter · ConnectedComponentEngine.hpp:452 — (overflow) Provisional labels are uint32 with no limit check; more than 4,294,967,295 runs (only reachable on very large out-of-core volumes) wrap and merge labels. ConnectedComponentImageFilter#1

  • WRONG_DATA · ConvertColorToGrayScaleFilter · ColorToGrayScale.cpp:102 — (cast) Weights that sum to 1.01 pass the check (line 37); white (255, 255, 255) gives 258, which is cast to uint8 with no clamp (also line 108 and Scanline). ConvertColorToGrayScaleFilter#3

  • WRONG_DATA · CreateColorMapFilter · CreateColorMapDirect.cpp:167 — (range) The range is seeded from value 0; float32 [NaN, 0.0, 0.5, 1.0] gives a NaN range and every element gets the first color. Same in Scanline. CreateColorMapFilter#1

  • WRONG_DATA · CurvatureFlowImageFilter · FiniteDifferenceEngine.hpp:2165 — (cast) The final write uses static_cast<T> (also lines 1510, 1694, 2307); uint8 input with Time Step = 10 diverges outside [0, 255], and spacing 0 gives NaN. No Time Step or spacing check exists. CurvatureFlowImageFilter#1

  • WRONG_DATA · ExpImageFilter · ExpImageFilter.cpp:23 — (cast) A uint8 input value of 10 gives exp(10) = 22026, which is cast to uint8 with no saturation. ExpImageFilter#1

  • WRONG_DATA · ExpNegativeImageFilter · ExpNegativeImageFilter.cpp:23 — (cast) An int8 value of -5 gives 148.4, and an int32 value of -22 gives more than INT32_MAX; both are cast with no saturation. ExpNegativeImageFilter#1

  • WRONG_DATA · HConvexImageFilter · ImageProcessingFilterUtilities.hpp:2102 — (cast) int16 input with Height = 2.5: each voxel is truncated toward zero after the offset, so positive and negative voxels move by different amounts. ITK converts Height to the pixel type once. HConvexImageFilter#1

  • WRONG_DATA · HMinimaImageFilter · ImageProcessingFilterUtilities.hpp:2102 — (cast) Same shared marker loop: int16 voxels -12 and +12 with Height = 2.5 get different offsets. HMinimaImageFilter#1

  • WRONG_DATA · Log10ImageFilter · Log10ImageFilter.cpp:23 — (cast) A uint8 value of 0 gives -inf, and a negative int16 value gives NaN; both are cast to the integer output type. Log10ImageFilter#1

  • WRONG_DATA · LogImageFilter · LogImageFilter.cpp:23 — (cast) A uint8 value of 0 gives -inf, and a negative signed value gives NaN; both are cast to the integer output type. LogImageFilter#1

  • WRONG_DATA · MorphologicalWatershedFromMarkersImageFilter · ImageProcessingFilterUtilities.hpp:5520 — (cast) An int64 marker label of -1 becomes 0xFFFFFFFF (the reserved border value), and 4294967296 becomes 0. Reject such labels with an error. MorphologicalWatershedFromMarkersImageFilter#1

  • WRONG_DATA · OtsuMultipleThresholdsImageFilter · StreamingStatistics.hpp:481 — (range) ComputeArrayMinMax seeds from the first value; a float32 NaN at index 0 gives a NaN histogram range, and every voxel gets the Label Offset. OtsuMultipleThresholdsImageFilter#2

  • WRONG_DATA · OtsuMultipleThresholdsImageFilter · OtsuMultipleThresholdsImageFilter.cpp:42 — (cast) Label Offset = 255 with Number Of Thresholds = 1 wraps the top class to 0 in the uint8 output. Add a preflight error. OtsuMultipleThresholdsImageFilter#3

  • WRONG_DATA · ReadGrainMapper3DFilter · ReadGrainMapper3D.cpp:403 — (cast) With Create Compatible IPFColor Data = true, an IPF component of 1.2, -0.1 or NaN is cast to uint8 with no clamp. ReadGrainMapper3DFilter#5

  • WRONG_DATA · ResampleImageGeomFilter · ImageGeometryResample.cpp:271 — (truncation) Dimensions are truncated from float32; 100 cells with Exact Dimensions X = 45 give 44, and Scale Factor 150% of 10 cells gives 14. ResampleImageGeomFilter#1

  • WRONG_DATA · SmoothingRecursiveGaussianImageFilter · RecursiveGaussianEngine.hpp:2398 — (cast) int32 2147483647 rounds to 2^31 in float32 and casts to INT32_MIN on x86; Sigma = +inf passes ValidatePositiveSigma and gives NaN. SmoothingRecursiveGaussianImageFilter#1

  • WRONG_DATA · SqrtImageFilter · SqrtImageFilter.cpp:23 — (cast) A signed integer value of -4 gives NaN, which is cast to the integer output type (INT_MIN on x86, 0 on ARM). SqrtImageFilter#1

  • WRONG_DATA · SquareImageFilter · SquareImageFilter.cpp:25 — (cast) A uint8 value of 16 gives 256.0, which is cast to uint8 with no saturation. Use SaturateCastFromDouble<U> as Sigmoid does. SquareImageFilter#1

  • WRONG_DATA · TanImageFilter · TanImageFilter.cpp:23 — (cast) A uint8 value of 2 gives tan(2) = -2.185, which is cast to uint8 (254 on x86, 0 on ARM). TanImageFilter#1

  • WRONG_DATA · ThresholdMaximumConnectedComponentsImageFilter · ImageProcessingFilterUtilities.hpp:4625 — (overflow) The bisection uses upperBound - lowerBound in T; int32 values -2e9 and 2e9 overflow, and the loop stops with an arbitrary threshold. ThresholdMaximumConnectedComponentsImageFilter#2

  • WRONG_DATA · WriteImageFilter · WriteImageDirect.cpp:226 — (range) With Create Color Table = true, a float NaN at tuple 0 seeds the range, and every pixel gets the first color. Same in WriteImageScanline. WriteImageFilter#3

  • WRONG_DATA · WriteLAMMPSFileFilter · WriteLAMMPSFile.cpp:73 — (range) The minimum starts at 1e9 and the maximum at 0.0; vertices with all x in [-10, -1] give a box upper bound of 0. WriteLAMMPSFileFilter#2

  • WRONG_DATA · WriteVtkRectilinearGridFilter · WriteVtkRectilinearGrid.cpp:61 — (overflow) CELL_DATA %d with static_cast<int>(totalCells) wraps above INT_MAX cells (for example 1300^3), so the header does not match the data. WriteVtkRectilinearGridFilter#4

  • MINOR · ComputeGBPDMetricBasedFilter · ComputeGBPDMetricBased.cpp:399 — (overflow) int numSamplePtsWholeSphere = 2 * NumSamplPts overflows for Number of Sampling Points = 1100000000; preflight only warns above 5000. ComputeGBPDMetricBasedFilter#7

  • MINOR · ComputeTriangleGeomVolumesFilter · DataArrayUtilities.cpp:386 — (overflow) ValidateFeatureIdsToFeatureAttributeMatrixIndexing compares int32 max with usize; when every label is -1 and ignoreNegativeValues is true, -1 becomes SIZE_MAX and gives a false -5351 error. ComputeTriangleGeomVolumesFilter#5

  • MINOR · ReadGrainMapper3DFilter · GrainMapper3DUtilities.cpp:250 — (truncation) AbsorptionCT dimensions are extent / spacing truncated: 0.3 / 0.1 gives 2, so a valid 3x3x3 file fails at execute; spacing 0 casts infinity. Read the dimensions from the dataset, as LabDCT does. ReadGrainMapper3DFilter#2

  • MINOR · ComputeGBCDMetricBasedFilter · ComputeGBCDMetricBased.cpp:455 — Doubling Number of Sampling Points in signed int can overflow before whole-sphere processing. The corresponding ComputeGBPDMetricBased finding is already listed separately. (origin: sweep)

Out of scope

  • Findings of this class in filters that have a V&V report are not in this issue. There is 1 such finding, in FillBadDataFilter. It is handled on a separate V&V branch.
  • Changing the output type of the ImageProcessing math filters for integer input is a behavior change. Do it only if decision 1(b) is chosen.

Activity

  1. changed the title [-]BUG: Unsafe numeric conversion and range computation in 39 filters[/-] [+]BUG: C15: Unsafe numeric conversion and range computation in 39 filters[/+] on Oct 22, 2026
  2. self-assigned this
    on Oct 23, 2026
  3. jmarquisbq commented on Nov 3, 2026

    @jmarquisbq
    Contributor

    C15 ImageProcessing implementation and verification

    Three coordinated draft PRs address 19 of the 46 findings across 18 of the 39 filters.

    • simplnx #1888 implements the numeric fixes, updates filter help, and migrates affected examples.
    • SimplnxOoc #11 checks the same contracts with real disk-backed arrays, mixed masks, and representative saved and exported outputs.
    • DREAM3DNX Windows packaging companion preserves dependency search paths for the coordinated Windows package.

    The implemented filters are Acos, Asin, Exp, ExpNegative, Log, Log10, Sqrt, Square, Tan, HConvex, HMinima, CurvatureFlow, SmoothingRecursiveGaussian, ConnectedComponent, MorphologicalWatershedFromMarkers, OtsuMultipleThresholds, ThresholdMaximumConnectedComponents, and WriteImage. The fixes cover math output types, checked integer conversions, native bounds, nonfinite policies, label capacity, and image export ranges.

    The 27 remaining findings across 21 filters stay open here. The coordinated PRs document their merge order and pending manual package checks. The HTML review companion records the per-filter decisions and evidence limits.

  4. joeykleingers commented on Nov 11, 2026

    @joeykleingers
    Contributor

    FYI from #1867: its fix for ComputeArrayHistogramByFeature (#1867 item ComputeArrayHistogramByFeatureFilter#2) changes the shared maximum seed at HistogramUtilities.hpp:394, which also fixes ComputeArrayStatisticsFilter#2 here. The rest of the Statistics and bounds group, CreateColorMap and ComputeTriangleGeomVolumes stay with this issue's plan, and #1867 does not change them. If your local histogram branch also edits that helper, whichever change lands second will rebase.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions