﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
6099	Low level issues with arrays in Windows	Francesco Casella	Mahder Alemseged Gebremedhin	"While running a large model of a FEM multibody system, I get this runtime error
{{{
index[1] == 0, size == 1

Simulation process failed. Exited with code 3.
}}}
This is caused by [https://github.com/OpenModelica/OpenModelica/blob/master/OMCompiler/SimulationRuntime/c/util/index_spec.c#L63 this function call].

@adrpo found that the same issue takes place when running {{{Modelica.Magnetic.FundamentalWave.Examples.BasicMachines.SMEE_Generator_MultiPhase.sim}}} with OMEdit on Windows. The same model runs fine on Linux on the testerver [https://libraries.openmodelica.org/branches/master/Modelica_3.2.3/files/Modelica_3.2.3_Modelica.Magnetic.FundamentalWave.Examples.BasicMachines.SMEE_Generator_MultiPhase.sim works fine]. 

More specifically, the error is triggered when invoking the function [https://github.com/modelica/ModelicaStandardLibrary/blob/master/Modelica/Electrical/Machines/SpacePhasors/Functions/ToSpacePhasor.mo ToSpacePhasor], involving a parameter array which is declared but not used in the function body. @adrpo checked the execution of the corresponding function and reports:
  
  All I can tell is that some very fishy is happening with the stack. Sometime between this call:
  {{{
  create_index_spec(&tmp18, 2, (0),
  make_index_array(1, (int) tmp15++), 'S', (1), (int*)0, 'W');
  }}}
  and this call (which is just one after the other):
  {{{
  indexed_assign_real_array(
    __omcQ_24tmpVar42, &__omcQ_24tmpVar43, &tmp18);
  }}}
  tmp18 is overwritten with bad data which triggers the assert.

  Somehow on Linux, valgrind doesn't find any issue which leads me to believe it might be a GCC 5.3 optimization bug. Other strange stuff is that the model runs fine in the terminal but gets you the error via gdb or OMEdit.

Maybe the solution could be to go ahead with #5307 and use a more recent version of gcc on Windows (or clang), since the currently used version of gcc is more than four years old, if I'm not mistaken.


"	defect	closed	blocker	1.17.0	Code Generation		fixed		lucciud@… Adrian Pop davide10.mariani@…
