BUG: C08: Sub-call results and warnings discarded in 22 filters

Abierto
#1,868 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 6 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cpp
Área
backend, testing

Línea de trabajo

Start with the 22 findings in the issue checklist and inspect each named source location, beginning with the dropped Result or unchecked stream described there. Add a failing unit test for each finding before fixing it, following the issue’s test guidance; run the relevant tests serially. Done means each finding is verified and fixed while preserving error codes, messages, and earlier warnings, with writer failures preventing AtomicFile commits.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Summary

Many filters call a function that returns a Result<> (or a stream that has an error state) and then do not use what it returns. Errors are lost and the filter reports success, or warnings are lost because a later Result replaces the earlier one. For file writers, an unchecked stream lets AtomicFile commit a truncated file as a success.

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

Mechanism

Result<> is not marked [[nodiscard]] (src/simplnx/Common/Result.hpp), and AbstractDataStore::copyFrom is not either. The compiler does not warn when a caller drops the value. The pattern has these forms:

  • Result discarded. The call's return value is ignored (converter(...), copyFrom(...), ExecuteDataFunction(...), algorithm.operator()(false), rename(...)), or a worker's stored error is never returned.
  • Result replaced. The code returns a new warning or error (return MakeWarningVoidResult(...), result = MakeWarningVoidResult(...) in a loop, return MakeErrorResult(-50011, ...)) instead of merging it into the existing Result. Earlier warnings and the real error text are lost.
  • Wrong or zero error code. A sub-call's error code is passed on even when it is 0, so the caller treats the failure as success.
  • Stream state not checked. A writer never checks fail()/bad() after writing, then commits the AtomicFile. A disk-full or I/O error gives a truncated file and success.
  • Preflight result not returned. MakePreflightErrorResult(...) is called without return.

Example (SurfaceNetsDirect::operator()). windingResult can hold warning -56730 (unrepairable triangles). The two early returns send only the new warning, so -56730 is lost:

  if(m_InputValues->BoundingBoxSkinMode == BoundingBoxSkinMode::k_BackgroundBackedWallsOnly && windingResult.valid())
  {
    if(triangleGeom.getNumberOfFaces() == 0)
    {
      return MeshingUtilities::MakeEmptyMeshWarning(m_InputValues->TriangleGeometryPath, m_DataStructure.getDataRefAs<Int32Array>(m_InputValues->FeatureIdsArrayPath).getNumberOfTuples(),
                                                    triangleGeom.getNumberOfVertices());
    }
    if(suppressedFaceCount == 0)
    {
      return MeshingUtilities::MakeNoFacesPrunedWarning(m_InputValues->TriangleGeometryPath);
    }
  }

Source: src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNetsDirect.cpp#L593-L604

Fixed form. PR #1767 (commit 53c678dfe) fixed the same code in QuickSurfaceMesh with MergeResults:

    if(suppressedFaceCount == 0)
    {
      return MergeResults(std::move(windingResult), MeshingUtilities::MakeNoFacesPrunedWarning(m_InputValues->TriangleGeometryPath));
    }

Source: src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/QuickSurfaceMeshDirect.cpp#L311-L314

Rule

  • Never drop a Result. Return it, or merge it into the Result that the function returns. Keep earlier warnings.
  • An error from a sub-call keeps its own code and message. You can add context, but do not replace it with a generic code.
  • A file writer checks the stream state after the last write (and after flush/close). On failure it returns an error, so the AtomicFile is not committed.
  • Every MakePreflightErrorResult(...) is returned.
  • Checks belong in preflight unless they need DataArray values. Remove execute-time checks that a new preflight check makes unreachable.

Decision needed:

  • ExecuteProcessFilter, nonzero exit status: (a) return an error, or (b) return a warning with the exit code. See #1811.
  • DeleteDataFilter, multi-parented object: (a) keep building the delete actions and add warning -61501, or (b) return an error.

How to fix

  1. Find each dropped value. Search the algorithm for calls whose return value is not assigned, and for return Make...Result( after a Result result was filled.
  2. Merge with MergeResults (src/simplnx/Common/Result.hpp, line 259 at 419f9db35). For a warning in a loop, use result.warnings().push_back({code, msg}).
  3. Return a stored worker result. In GeometryTransformation.cpp, the image path already returns filterProgressCallback.takeResult() (line 499); do the same in applyNodeGeometryTransformation (line 517). takeResult() is in src/simplnx/Utilities/ImageRotationUtilities.hpp.
  4. In parallel tasks (PadImageGeometry), keep the first failed copyFrom Result in the task and return it after the loop.
  5. For writers: after the last write, call flush(), then check fail()/bad(). Return an error before AtomicFile::commit().
  6. When a sub-call can return code 0 on failure (ReadChannel5Data), return a fixed negative code from the filter's own range.
  7. New error codes: use the filter's existing error-code range. Codes are more negative than -10000, and each filter uses one range of 100 codes. Check uniqueness with git grep -nE -- "-NNNN([^0-9]|$)" (not \b) on develop and on open pull request refs.
  8. Do not add [[nodiscard]] to Result in this work. That change affects the whole code base and needs its own issue.

How to test

Write a unit test that fails on develop first. Then fix the code.

  • Lost warning: set up input that gives both warnings. Assert that the result holds both warning codes.
  • Lost or replaced error: set up input that makes the sub-call fail. Assert that the execute (or preflight) result is invalid and holds the sub-call's own error code.
  • Missing return in preflight: a preflight test with the invalid value. Assert the expected error code.
  • Writer stream state: if you can make the stream fail in a test (for example, an output path to a full or read-only location that opens but fails on write), assert an error and that the destination file is not replaced. If you cannot make the failure in a portable test, write that in the pull request with the reason.
  • Out-of-core I/O failure (ApplyTransformationToGeometry, PadImageGeometry, ComputeEuclideanDistMap): use a test data store that fails copyIntoBuffer/copyFromBuffer or creation, if one exists. If none exists, say so in the pull request.
  • If the filter has Direct and Scanline algorithms (SurfaceNets, ComputeEuclideanDistMap, CreateColorMap), test both through the existing algorithm-selection test scope.
  • Value checks need an independent expected result (oracle), not the output of the code under test.

Conventions

  • One pull request 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 in the pull request and on this issue with the reason. Do not force a fix.
  • Value checks need an independent expected result (oracle).
  • 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 per-filter documentation sentences about input requirements. 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 · ComputeEuclideanDistMapFilter · ComputeEuclideanDistMapScanline.cpp:898 — On the Scanline path with float output, DataStoreUtilities::CreateDataStore<int64> can return nullptr for the scratch store, and line 899 dereferences it with no check. ComputeEuclideanDistMapFilter#3
  • CRASH · ReadGrainMapper3DFilter · GrainMapper3DUtilities.cpp:188 — The return of getDatasetInfo is ignored and dims[2], dims[1], dims[0] are read from a possibly empty vector; lines 206-208 index Extent/Center/VirtualShift with no size check. Undefined behavior in preflight. ReadGrainMapper3DFilter#3
  • WRONG_DATA · ApplyTransformationToGeometryFilter · GeometryTransformation.cpp:517 — applyNodeGeometryTransformation returns {} and drops the errors stored in filterProgressCallback, so a failed out-of-core chunk reports success with vertices only partly transformed. ApplyTransformationToGeometryFilter#12
  • WRONG_DATA · DeleteDataFilter · DeleteDataFilter.cpp:99 — For a multi-parented object, preflight returns only warning -61501 and drops every delete action already added, so the pipeline runs and deletes nothing. The message names a "Delete DataPath" mode that does not exist. DeleteDataFilter#1
  • WRONG_DATA · ExtractPipelineToFileFilter · ExtractPipelineToFile.cpp:65 — The stream state is not checked after the write, and atomicFile.commit() replaces the destination with a possibly truncated file and reports success. ExtractPipelineToFileFilter#1
  • WRONG_DATA · PadImageGeometryFilter · PadImageGeometry.cpp:65 — The copyFrom Result is discarded in a parallel task, so failed row copies (for example negative X Min & Max Padding {-1,0}) are skipped and execute reports success. PadImageGeometryFilter#4
  • WRONG_DATA · ReadChannel5DataFilter · ReadChannel5Data.cpp:103 — For a .cpr with no phases, the reader's error code (0) is returned, so the filter continues with CrystalStructures[0]=0 (Hexagonal_High, not 999) and an empty MaterialName[0]. ReadChannel5DataFilter#3
  • WRONG_DATA · RenameDataObjectFilter · RenameDataAction.cpp:140 — The bool from rename() is ignored. With Allow Overwrite on and an existing sibling (preflight) or an invalid New Name, the rename fails but apply() reports success. RenameDataObjectFilter#2
  • WRONG_DATA · WriteGBCDTriangleDataFilter · WriteGBCDTriangleData.cpp:98 — outStream.write() is never checked and the filter commits the AtomicFile, so an I/O error (for example a full disk) gives a truncated .ph file and success. WriteGBCDTriangleDataFilter#2
  • MINOR · ComputeBiasedFeaturesFilter · ComputeBiasedFeatures.cpp:36 — operator() drops the Result of findBoundingBoxFeatures()/2D() and returns {}. Error -54900 is reachable only when the algorithm is called outside IFilter. ComputeBiasedFeaturesFilter#4
  • MINOR · ComputeTwinBoundariesFilter · ComputeTwinBoundaries.cpp:503 — return MakeWarningVoidResult(-93213, ...) drops result, which can hold the -93211 non-cubic warning. ComputeTwinBoundariesFilter#3
  • MINOR · ConditionalSetValueFilter · ConditionalSetValueFilter.cpp:126 — When CheckValueConverts fails, its errors are dropped, and the message prints the DataObject type enum as an integer, not the DataType name (for example New Value "300" on uint8). ConditionalSetValueFilter#4
  • MINOR · ConvertHexGridToSquareGridFilter · ConvertHexGridToSquareGrid.cpp:362 — The converter Result is ignored, so real errors become generic -77751. If AtomicFile::Create fails, m_Valid stays true and commitAllFiles calls .value() on an error Result. ConvertHexGridToSquareGridFilter#4
  • MINOR · CreateColorMapFilter · CreateColorMapDirect.cpp:339 — The ExecuteDataFunction result is discarded, so the empty-array error -34381 is never reported and the filter succeeds with an empty RGB output. CreateColorMapFilter#5
  • MINOR · ExecuteProcessFilter · ExecuteProcess.cpp:136 — status from process.wait is never read, so a command that exits with a nonzero code (for example false) reports success. (related: #1811) ExecuteProcessFilter#6
  • MINOR · MergeTwinsFilter · MergeTwins.cpp:248 — result = MakeWarningVoidResult(-23500, ...) in the loop replaces earlier warnings, so only the last non-m3m phase is reported. MergeTwinsFilter#4
  • MINOR · ReadDeformKeyFileV12Filter · ReadDeformKeyFileV12Filter.cpp:127 — algorithm.operator()(false) in preflight discards the Result, so parse errors (for example -2013) and warnings appear only at execute. ReadDeformKeyFileV12Filter#4
  • MINOR · ReadH5EbsdFilter · ReadH5Ebsd.cpp:427 — An error from the RotateEulerRefFrame sub-filter is replaced by generic -50011, and warnings from both sub-filters are never passed on. ReadH5EbsdFilter#7
  • MINOR · SurfaceNetsFilter · SurfaceNetsDirect.cpp:602 — The empty-mesh and no-faces-pruned returns drop winding warning -56730. Scanline has the same code at lines 1104-1115. SurfaceNetsFilter#3
  • MINOR · WriteNodesAndElementsFilesFilter · WriteNodesAndElementsFiles.cpp:76 — The write loop never checks the stream state and returns {}, so a disk-full or I/O error leaves a truncated file and success. WriteNodesAndElementsFilesFilter#2
  • MINOR · WriteSPParksSitesFilter · WriteSPParksSites.cpp:151 — flush/close are not followed by a stream-state check, and the filter commits through AtomicFile, so a disk-full truncation is committed as success. WriteSPParksSitesFilter#2
  • MINOR · WriteStatsGenOdfAngleFileFilter · WriteStatsGenOdfAngleFileFilter.cpp:118 — MakePreflightErrorResult(-9400/-9401, ...) is called without return, so an invalid Default Weight or Default Sigma passes preflight. Also fix the InValid test so that it sets the Phases argument. WriteStatsGenOdfAngleFileFilter#1

Already fixed or in progress

  • PR #1767 (merged, commit 53c678dfe): ReadImageStackFilter#7 (dropped warnings in ReadImageStackFilter) and QuickSurfaceMeshFilter#6 (winding warning dropped, fixed with MergeResults).

Related issues

  • #1811 — BUG: Execute Process ignores nonzero child exit status (same as ExecuteProcessFilter#6)

Out of scope

  • Findings in filters that have a V&V report are excluded from this issue. There is 1 such filter: RegularizeZSpacingFilter. A separate V&V branch handles it.
  • Marking Result as [[nodiscard]] across the code base. That needs its own issue.
Lenguaje dominante
C++
Estrellas
18
Forks
15
Merge medio
4 d 23 h
PR fusionados (30 d)
42

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de BlueQuartzSoftware/simplnx

Todos los issues de BlueQuartzSoftware/simplnx

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.