BUG: QuickSurfaceMesh preflight crashes when the grid geometry has no Cell Attribute Matrix
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
Direzione di ricerca
Leggi QuickSurfaceMeshFilter.cpp, in particolare QuickSurfaceMeshFilter::preflightImpl() vicino al recupero del conteggio delle celle, ed esamina QuickSurfaceMeshFilterTest.cpp. Sostituisci la sorgente del conteggio delle celle con il conteggio delle celle della geometria e aggiungi il test fornito per Image Geometry e un caso Rectilinear Grid. Esegui il filtro ctest indicato; il lavoro è completato quando entrambi i casi superano il preflight senza una Cell Attribute Matrix.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
QuickSurfaceMesh crashes during preflight when the selected grid geometry has no Cell Attribute Matrix. Preflight reads the cell count from the geometry's Cell Attribute Matrix without checking that one exists, so it dereferences a null pointer and the process ends with a segmentation fault.
- Expected: preflight returns a result. With Attempt to Fix Problem Voxels off, Feature Ids that live outside the geometry are allowed, so a consistent input (one Feature Id per cell) should preflight cleanly.
- Actual: the application or test process crashes (SIGSEGV).
- Commit:
developat 2eb6b878f6ff408d1454754d4c0e63edd676d7e0.
Steps to Reproduce
- Create an Image Geometry with dimensions 4 x 1 x 1 and no Cell Attribute Matrix.
- Create an
int32DataArray with 4 tuples and 1 component in a DataGroup outside the geometry, for exampleElsewhere/Feature Ids. - Preflight Quick Surface Mesh with:
- Grid Geometry: the Image Geometry from step 1
- Cell Feature Ids: the array from step 2
- Attempt to Fix Problem Voxels: off
- every other parameter at its default
- Preflight crashes.
Cause
QuickSurfaceMeshFilter::preflightImpl() takes the number of cells from the Cell Attribute Matrix:
const auto& gridGeom = dataStructure.getDataRefAs<IGridGeometry>(pGridGeomDataPath);
const usize elementTupleCount = gridGeom.getCellData()->getNumberOfTuples();
IGridGeometry::getCellData() returns nullptr when no Cell Attribute Matrix is assigned. Nothing before this line checks for that:
- The Grid Geometry parameter only checks the geometry type (Image or Rectilinear Grid).
- The Cell Feature Ids parameter only checks the data type and component shape. It does not require the array to be in the geometry.
The value is used only to check the tuple count of the Cell Attribute Arrays to Transfer (error -76531):
Verification Unit Test
Add to src/Plugins/SimplnxCore/test/QuickSurfaceMeshFilterTest.cpp, with #include "simplnx/DataStructure/DataGroup.hpp" next to the other DataStructure includes:
TEST_CASE("SimplnxCore::QuickSurfaceMeshFilter: Geometry without a Cell Attribute Matrix", "[SimplnxCore][QuickSurfaceMeshFilter]")
{
UnitTest::LoadPlugins();
// The Image Geometry has 4 cells but no Cell Attribute Matrix. Feature Ids lives in a separate DataGroup
// and has one tuple per cell, so the geometry and the Feature Ids array are consistent.
DataStructure dataStructure;
auto* imageGeomPtr = ImageGeom::Create(dataStructure, "Image Geometry");
REQUIRE(imageGeomPtr != nullptr);
imageGeomPtr->setDimensions({4, 1, 1});
imageGeomPtr->setOrigin({0, 0, 0});
imageGeomPtr->setSpacing({1, 1, 1});
REQUIRE(imageGeomPtr->getCellData() == nullptr);
auto* elsewherePtr = DataGroup::Create(dataStructure, "Elsewhere");
REQUIRE(elsewherePtr != nullptr);
auto* featureIdsPtr = Int32Array::CreateWithStore<DataStore<int32>>(dataStructure, "Feature Ids", {4}, {1}, elsewherePtr->getId());
REQUIRE(featureIdsPtr != nullptr);
(*featureIdsPtr)[0] = 1;
(*featureIdsPtr)[1] = 1;
(*featureIdsPtr)[2] = 2;
(*featureIdsPtr)[3] = 2;
QuickSurfaceMeshFilter filter;
Arguments args;
args.insertOrAssign(QuickSurfaceMeshFilter::k_GridGeometryDataPath_Key, std::make_any<DataPath>(DataPath({"Image Geometry"})));
args.insertOrAssign(QuickSurfaceMeshFilter::k_CellFeatureIdsArrayPath_Key, std::make_any<DataPath>(DataPath({"Elsewhere", "Feature Ids"})));
args.insertOrAssign(QuickSurfaceMeshFilter::k_FixProblemVoxels_Key, std::make_any<bool>(false));
// Preflight must return a result. It must not dereference the missing Cell Attribute Matrix.
auto preflightResult = filter.preflight(dataStructure, args);
SIMPLNX_RESULT_REQUIRE_VALID(preflightResult.outputActions);
}
Run only this test:
ctest -R "QuickSurfaceMeshFilter: Geometry without a Cell Attribute Matrix" --output-on-failure
Output at 2eb6b87 (simplnx-Rel, macOS arm64):
QuickSurfaceMeshFilterTest.cpp:108: FAILED:
{Unknown expression after the reported line}
due to a fatal error condition:
SIGSEGV - Segmentation violation signal
test cases: 1 | 1 failed
assertions: 6 | 5 passed | 1 failed
842 - SimplnxCore::QuickSurfaceMeshFilter: Geometry without a Cell Attribute Matrix (SEGFAULT)
Proposed Fix
In QuickSurfaceMeshFilter::preflightImpl(), take the cell count from the geometry instead of its Cell Attribute Matrix:
- const usize elementTupleCount = gridGeom.getCellData()->getNumberOfTuples();
+ const usize elementTupleCount = gridGeom.getNumberOfCells();
getNumberOfCells() is the count the Cell Attribute Matrix must match, so the -76531 check on Cell Attribute Arrays to Transfer behaves the same for valid geometries. A geometry without a Cell Attribute Matrix then has no arrays to transfer, and preflight continues.
Add a Rectilinear Grid case to the test as well, because the filter accepts both geometry types.
Notes
- Found while reviewing #1829. That PR requires Feature Ids to be in the geometry's Cell Attribute Matrix only when Attempt to Fix Problem Voxels is on, and it adds a check that Feature Ids has one tuple per cell (
-76533). Neither check stops this crash when the option is off: the same line is still reached at the PR head. This was found by reading the code; the test was not run on the PR branch. - The QuickSurfaceMesh algorithm does not read the Cell Attribute Matrix during execute (checked by a search of
Algorithms/QuickSurfaceMesh*.cpp). The only dereference found is this one in preflight.
- Lingua principale
- C++
- Stelle
- 18
- Fork
- 15
- Merge medio
- 3g 22h
- PR unite (30g)
- 20
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di BlueQuartzSoftware/simplnx
-
bug Filter
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
BlueQuartzSoftware/simplnx#1860 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
documentation
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
BlueQuartzSoftware/simplnx#1847 ·
I maintainer di solito rispondono entro 3 giorni
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
BlueQuartzSoftware/simplnx#1846 ·
I maintainer di solito rispondono entro 3 giorni
-
bug Filter
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
BlueQuartzSoftware/simplnx#1844 ·
I maintainer di solito rispondono entro 3 giorni
-
bug Filter
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
BlueQuartzSoftware/simplnx#1825 ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di BlueQuartzSoftware/simplnx
Issue simili
-
[Bug] [Go] Ack returns nil when the server answers with a non-OK statusForse già presa @leizhiyuan l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
apache/rocketmq-clients#1465 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
cp-algorithms/cp-algorithms#1738 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
KhronosGroup/Vulkan-Tutorial#534 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 2 giorni
-
bug IO
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
MrNeRF/LichtFeld-Studio#3824 ·
I maintainer di solito rispondono entro 1 giorno