Fix crash in sector model export of an inverted cell box

A view without visible cells gives min > max, which underflowed the
sector size and threw std::length_error when allocating the arrays.

Call stack:
[0] performCrashLogging at ResInsight/ApplicationExeCode/RiaMainTools.cpp:178
[1] manageSegFailureSA(int, siginfo_t*, void*) at ResInsight/ApplicationExeCode/RiaMainTools.cpp:310
[5] manageTerminate() at ResInsight/ApplicationExeCode/RiaMainTools.cpp:249
[12] RigResdataGridConverter::exportGrid(QString const&, RigEclipseCaseData*, bool, cvf::Array<unsigned char> const*, cvf::Vector3<unsigned long> const&, cvf::Vector3<unsigned long> const&, cvf::Vector3<unsigned long> const&) at ResInsight/ApplicationLibCode/ReservoirDataModel/RigResdataGridConverter.cpp:83
[13] RicExportEclipseSectorModelFeature::exportGrid(RimEclipseView*, RicExportEclipseSectorModelUi const&) at ResInsight/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelFeature.cpp:167
[14] RicExportEclipseSectorModelFeature::executeCommand(RimEclipseView*, RicExportEclipseSectorModelUi const&, QString const&) at ResInsight/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelFeature.cpp:141
[15] RicExportEclipseSectorModelFeature::openDialogAndExecuteCommand(RimEclipseView*) at ResInsight/ApplicationLibCode/Commands/ExportCommands/RicExportEclipseSectorModelFeature.cpp:118
[16] caf::CmdFeature::actionTriggered(bool) at ResInsight/Fwk/AppFwk/cafCommand/cafCmdFeature.cpp:176
[25] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1879
[31] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1879
[43] RiuViewerCommands::displayContextMenu(QMouseEvent*) at ResInsight/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp:702
[47] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1879
[53] RiaGuiApplication::notify(QObject*, QEvent*) at ResInsight/ApplicationLibCode/Application/RiaGuiApplication.cpp:1879
[64] main at ResInsight/ApplicationExeCode/RiaMain.cpp:267
[65] __libc_start_main at :0
This commit is contained in:
Magne Sjaastad authored and Kristian Bendiksen committed 2026-10-19 09:41:18 +02:00
1 parent b2a85fb7a4
commit 596bbb8fe1
2 files changed
+28

No files matched your search

@@ -54,6 +54,10 @@ bool RigResdataGridConverter::exportGrid( const QString& resultFileName,
const RigMainGrid* mainGrid = eclipseCase->mainGrid();
cvf::Vec3st resolvedMax =
max.isUndefined() ? cvf::Vec3st( mainGrid->cellCountI() - 1, mainGrid->cellCountJ() - 1, mainGrid->cellCountK() - 1 ) : max;
// An inverted box, e.g. the visible cell range of a view without visible cells, underflows the sector size
if ( resolvedMax.x() < min.x() || resolvedMax.y() < min.y() || resolvedMax.z() < min.z() ) return false;
cvf::Vec3st sectorSize( resolvedMax.x() - min.x() + 1, resolvedMax.y() - min.y() + 1, resolvedMax.z() - min.z() + 1 );
RigGridExportAdapter gridAdapter( eclipseCase, min, resolvedMax, RigUniformRefinement( refinement, sectorSize ), cellVisibilityOverrideForActnum );