BUG: C04: Sibling DataArray tuple counts not compared in 13 filters

Đang mở
#1,864 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 6 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
backend

Hướng nghiên cứu

Start with CheckArraysHaveSameTupleCount in src/simplnx/Utilities/DataArrayUtilities.hpp and compare the listed filter preflight implementations with SilhouetteFilter.cpp. Work through the 13 findings in the issue checklist, adding tuple count validation and focused preflight tests for each filter, including optional inputs and different tuple counts where applicable. Done means every applicable finding is covered by a regression test and mismatched sibling arrays fail preflight with a filter-specific error.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

Summary

Many filters read two or more input DataArrays with the same index, but preflight does not compare their tuple counts. The selection parameters accept each DataArray from any Attribute Matrix, so the sibling inputs can have different tuple counts. Execute then takes its loop count from one DataArray and reads the others past their end, or it pairs values that do not belong together.

As of develop 419f9db35 (2026-10-21), there are 13 open findings in 13 filters: 8 CRASH, 4 WRONG_DATA, 1 MINOR. Each finding is a candidate. It was found and re-checked by reading code, not by running it.

Mechanism

A filter reads, for example, an Attribute Array and a Conditional Array (mask) tuple by tuple. It takes the loop count from one of them and assumes that the other has the same number of tuples. If the second DataArray has fewer tuples, the loop reads past its end (CRASH). If it has more tuples, the filter silently pairs each value with an unrelated value (WRONG_DATA). A third variant sizes the outputs from an Attribute Matrix but takes the loop count from an input DataArray, so the filter writes past the end of its outputs.

Example: ConditionalSetValueFilter preflight checks only the DataType of the Conditional Array. The Direct algorithm takes the loop count from the Attribute Array and reads the Conditional Array with the same index:

ConditionalSetValue.cpp#L110-L139

      auto& targetDataArray = dynamic_cast<DataArray<TargetType>&>(targetArray);
      const auto& conditionalDataArray = dynamic_cast<const DataArray<ConditionalType>&>(conditionalArray);
      const usize numTuples = targetDataArray.getNumberOfTuples();
      // ...
        const ConditionalType* conditionalValues = contiguousConditionalStore->data();
      // ...
            for(usize tupleIndex = tupleOffset; tupleIndex < tupleEnd; tupleIndex++)
            {
              if(static_cast<bool>(conditionalValues[tupleIndex]) != invertMask)
              {
                targetValues[tupleIndex] = replaceValue;
              }
            }

If the Attribute Array has 100 tuples and the Conditional Array has 10 tuples, the loop reads 90 values past the end of the Conditional Array.

The fixed form already exists on develop. SilhouetteFilter (fixed in #1765) compares the sibling tuple counts in preflight:

SilhouetteFilter.cpp#L112-L119

  if(pUseMaskValue && !CheckArraysHaveSameTupleCount(dataStructure, {pSelectedArrayPathValue, pMaskArrayPathValue, pFeatureIdsArrayPathValue}))
  {
    const auto& maskArray = dataStructure.getDataRefAs<IDataArray>(pMaskArrayPathValue);
    return MakePreflightErrorResult(-8977, fmt::format("Attribute Array to Silhouette DataArray '{}' ({} tuples), Mask Array DataArray '{}' ({} tuples), and Cluster Ids DataArray '{}' ({} tuples) "
                                                       "must have the same number of tuples.",
                                                       pSelectedArrayPathValue.toString(), clusterArray->getNumberOfTuples(), pMaskArrayPathValue.toString(), maskArray.getNumberOfTuples(),
                                                       pFeatureIdsArrayPathValue.toString(), clusterIds->getNumberOfTuples()));
  }

Rule

Input DataArrays that a filter reads with the same index must have the same tuple count. Check this in preflight. The DataArrays may be in any Attribute Matrix.

  • If the filter sizes its outputs from an Attribute Matrix, each input that sets the loop count must have the same tuple count as that Attribute Matrix.
  • If an input is an element DataArray of a geometry (cells, faces, edges, vertices), its tuple count must also equal the geometry's element count (see the companion class "Element DataArray tuple count not checked against the geometry").
  • Include optional inputs (for example a mask) in the check only when the option that uses them is on.

How to fix

  1. In preflightImpl, collect the paths of all inputs that the algorithm reads with the same index.
  2. Call CheckArraysHaveSameTupleCount(dataStructure, paths) from src/simplnx/Utilities/DataArrayUtilities.hpp. It returns bool. Alternatively call DataStructure::validateNumberOfTuples(paths), which returns an error string.
  3. When the outputs are sized from an Attribute Matrix (ComputeShapesTriangleGeomFilter#1, ComputeMomentInvariants2DFilter#2), compare the input tuple count with AttributeMatrix::getNumberOfTuples().
  4. When an index parameter selects an ensemble (WriteGBCDGMTFileFilter#4), also require the index to be less than the tuple count of every ensemble DataArray that is read with it.
  5. For PartitionGeometryFilter#2, compare the Vertex Mask tuple count with the vertex count of the node geometry. PR #1840 has a file-local helper validateVertexTupleCount in PartitionGeometryFilter.cpp for this.
  6. Write an error message that names each path and its tuple count, as SilhouetteFilter does.
  7. Error codes: use a new code in the filter's existing range. Filter error codes are more negative than -10000, and each filter uses one range (first code -47500 means all codes -47500..-47599). Check that the code is unique with git grep -nE -- "-NNNN([^0-9]|$)" (do not use \b) and also in the open PR refs.
  8. Remove any execute-time check that the new preflight check makes unreachable (for example the generic copyIntoBuffer failure -6030 paths in ComputeVectorColorsFilter and ComputeTwinBoundariesFilter). Do not keep duplicate checks.

How to test

  • Write the test first. It must fail on develop.
  • Preflight test: put one sibling input in a different Attribute Matrix with fewer tuples (for example 10 tuples against 100). Assert that preflight fails with the new error code. For the WRONG_DATA findings, add a second case with more tuples.
  • Positive test: siblings with equal tuple counts in different Attribute Matrices must pass preflight.
  • For an optional input, test that the check runs only when the option is on.
  • If the filter has more than one algorithm (for example Direct and Scanline), run the test for each one through the existing algorithm-selection test scope.
  • If a fix changes output values, compare them with an independent expected result (oracle), not with the code's own output.

Conventions

  • One PR for the whole class. One commit per filter.
  • Commit prefix BUG:. Add a Signed-off-by line. Do not add AI attribution.
  • Every fix starts with a unit test that fails on develop. If you cannot reproduce a finding, write that with the reason in the PR and on this issue. Do not force a fix.
  • Value checks need an independent expected result (oracle), not the code's own output.
  • Run ctest serially. Never use -j; the tests depend on each other.
  • Format with clang-format 19.1.1 and the repository .clang-format.
  • Do NOT add documentation sentences about input requirements to the filter pages. 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 that filter's V&V package (report, deviations, provenance, test tables). V&V documents reference DREAM3D 6.5.171 only.
  • Rebase on develop. Never merge develop into the branch.

Checklist

  • CRASH · ComputeGBCDMetricBasedFilter · ComputeGBCDMetricBasedFilter.cpp:180 — Average Euler Angles with fewer tuples than Phases is read out of bounds. ComputeGBCDMetricBasedFilter#3
  • CRASH · ComputeMomentInvariants2DFilter · ComputeMomentInvariants2D.cpp:445 — Feature Rect with more tuples than the Feature Attribute Matrix writes the outputs out of bounds. ComputeMomentInvariants2DFilter#2
  • CRASH · ComputeShapesTriangleGeomFilter · ComputeShapesTriangleGeom.cpp:534 — Centroids with more tuples than the Face Feature Attribute Matrix makes setValue write the outputs out of bounds. ComputeShapesTriangleGeomFilter#1
  • CRASH · ComputeSlipTransmissionMetricsFilter · ComputeSlipTransmissionMetricsFilter.cpp:103 — Neighbor List or Average Quaternions with fewer tuples than Feature Phases is read out of bounds. ComputeSlipTransmissionMetricsFilter#3
  • CRASH · ConditionalSetValueFilter · ConditionalSetValueFilter.cpp:109 — Conditional Array with fewer tuples than Attribute Array is read out of bounds. ConditionalSetValueFilter#1
  • CRASH · PartitionGeometryFilter · PartitionGeometryDirect.cpp:297 — Vertex Mask with fewer tuples than vertices is read out of bounds (PR #1840 adds only a type check). PartitionGeometryFilter#2
  • CRASH · WriteGBCDGMTFileFilter · WriteGBCDGMTFileFilter.cpp:112 — Crystal Structures with fewer tuples than GBCD is read out of bounds at index Phase of Interest. WriteGBCDGMTFileFilter#4
  • CRASH · WriteINLFileFilter · WriteINLFile.cpp:209 — Crystal Structures or Number of Features with fewer tuples than Material Names is read out of bounds (not fixed by PR #1840). WriteINLFileFilter#4
  • WRONG_DATA · ComputeBoundaryElementFractionsFilter · ComputeBoundaryElementFractionsFilter.cpp:85 — Surface Elements with more tuples than Feature Ids is silently paired with the wrong cells. ComputeBoundaryElementFractionsFilter#2
  • WRONG_DATA · ComputeFeaturePhasesBinaryFilter · ComputeFeaturePhasesBinaryFilter.cpp:86 — Mask with more tuples than Feature Ids is silently paired with the wrong cells (PR #1766 adds only the component shape). ComputeFeaturePhasesBinaryFilter#3
  • WRONG_DATA · ComputeMisorientationsFilter · ComputeMisorientationsFilter.cpp:130 — Phases is not compared with the Euler Angles arrays; a longer Phases is silently paired with the wrong angles. ComputeMisorientationsFilter#1
  • WRONG_DATA · ComputeVectorColorsFilter · ComputeVectorColors.cpp:70 — Mask with more tuples than the vector array gives wrong colors; a shorter one fails with the generic error -6030. ComputeVectorColorsFilter#2
  • MINOR · ComputeTwinBoundariesFilter · ComputeTwinBoundariesFilter.cpp:118 — Short Average Quaternions or Face Normals fail in execute with the generic error -6030, not a clear preflight error. ComputeTwinBoundariesFilter#2

Already fixed or in progress

These findings of this class are fixed on develop or in an open PR. They are not in the checklist.

  • Fixed on develop by #1765 (1986127eb):
    • SilhouetteFilter SilhouetteFilter#2
  • Fixed on develop by #1829 (419f9db35):
    • FillBadDataFilter FillBadDataFilter#2
  • Fixed in open PR #1766:
    • ComputeKMeansFilter ComputeKMeansFilter#4
    • ComputeKMedoidsFilter ComputeKMedoidsFilter#1
    • DBSCANFilter DBSCANFilter#2

Related issues

  • #1765 (merged): fixed SilhouetteFilter; its preflight check is the model for this class.
  • #1766 (open PR): enforces component shapes and DataTypes that filters read, and fixes the sibling tuple counts in ComputeKMeansFilter, ComputeKMedoidsFilter and DBSCANFilter. It adds only the component shape for ComputeFeaturePhasesBinaryFilter.
  • #1840 (open PR): adds cell tuple-count checks; it does not fix WriteINLFileFilter#4, ComputeMomentInvariants2DFilter#2 or PartitionGeometryFilter#2.

Out of scope

  • Findings in filters that have a V&V report are excluded: 4 findings in 3 filters, ComputeFeatureReferenceMisorientationsFilter, GroupMicroTextureRegionsFilter and WritePoleFigureFilter. They are handled on a separate V&V branch.
  • Element DataArrays checked against the geometry element count. That is the companion class "Element DataArray tuple count not checked against the geometry", except where a finding here needs both checks.
  • Execute-time checks of Feature Id values against the Feature Attribute Matrix. That is a different class.
Ngôn ngữ chính
C++
Star
18
Fork
15
Merge trung bình
4 ngày 23 giờ
Pull request đã merge (30 ngày)
42

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của BlueQuartzSoftware/simplnx

Tất cả issue của BlueQuartzSoftware/simplnx

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.