From edd6c6fe858a13aaa3efd07a7130bba0d56f73c6 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Wed, 1 Sep 2021 17:08:38 +0200 Subject: [PATCH] [bugfix] Prevent segmentation fault for unkown keywords in parallel. If there are unknown keywords and the parser throws an exception then we nevertheless broadcasted the eclipseState and schedule. Unfortunately, these might be null pointers in this case and the serializer will run into a segmentation fault (e.g. when serializing the non-existent TableManager) Broadcasting is now only done if parsing was successful. --- opm/simulators/utils/readDeck.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/opm/simulators/utils/readDeck.cpp b/opm/simulators/utils/readDeck.cpp index 181b71099..42550d686 100644 --- a/opm/simulators/utils/readDeck.cpp +++ b/opm/simulators/utils/readDeck.cpp @@ -324,9 +324,17 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr& d eclipseState = std::make_unique(); } + // In case of parse errors eclipseState/schedule might be null + // and trigger segmentation faults in parallel during broadcast + // (e.g. when serializing the non-existent TableManager) + auto comm = Dune::MPIHelper::getCollectiveCommunication(); + parseSuccess = comm.min(parseSuccess); try { - Opm::eclStateBroadcast(*eclipseState, *schedule, *summaryConfig); + if (parseSuccess) + { + Opm::eclStateBroadcast(*eclipseState, *schedule, *summaryConfig); + } } catch(const std::exception& broadcast_error) { @@ -344,8 +352,6 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr& d errorGuard->clear(); } - - auto comm = Dune::MPIHelper::getCollectiveCommunication(); parseSuccess = comm.min(parseSuccess); if (!parseSuccess)