diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 01269875..25c754ef 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -932,6 +932,13 @@ def simulate(self, resultfile: Optional[str] = None, simflags: Optional[str] = N returncode = om_cmd.run() # and check returncode *AND* resultfile if returncode != 0 and self.resultfile.is_file(): + # check for an empty (=> 0B) result file which indicates a crash of the model executable + # see: https://github.com/OpenModelica/OMPython/issues/261 + # https://github.com/OpenModelica/OpenModelica/issues/13829 + if self.resultfile.stat().st_size == 0: + self.resultfile.unlink() + raise ModelicaSystemError("Empty result file - this indicates a crash of the model executable!") + logger.warning(f"Return code = {returncode} but result file exists!") self.simulationFlag = True