--stepSize=0 is accepted and then hangs (or aborts) instead of being rejected
What happens
Passing --stepSize=0 makes OMSimulator accept the value, print maximum step size ... 0.000000, and then never finish. It writes a result file header and nothing else. On some FMUs it does not hang but aborts with pure virtual method called and dumps core.
A step size of zero cannot produce a simulation, so it seems better to reject it with a message than to accept it and stop making progress.
How to reproduce
model HelloWorld
Real x(start = 1, fixed = true);
equation
der(x) = -x;
annotation(experiment(StartTime = 0, StopTime = 1));
end HelloWorld;
omc -q build.mos # buildModelFMU(HelloWorld, version="2.0", fmuType="me", platforms={"static"})
# fine: 502 steps, 12350 byte result
OMSimulator -r=ok.mat --startTime=0 --stopTime=1 --tolerance=1e-6 HelloWorld.fmu
# hangs until killed, 350 byte result
OMSimulator -r=bad.mat --startTime=0 --stopTime=1 --stepSize=0 --tolerance=1e-6 HelloWorld.fmu
The second command produces:
info: *** FMU Simulation Info ***
- model: HelloWorld (model exchange)
- path: HelloWorld.fmu
- startTime: 0.000000
- stopTime: 1.000000
- tolerance: 0.000001
- stepSize: 0.000000
info: maximum step size for 'HelloWorld.root': 0.000000
info: Result file: bad.mat (bufferSize=1)
and then makes no further progress; killed after 60 s.
On an FMU generated from ExternData.Examples.INITest the same argument gives, instead of the hang:
pure virtual method called
terminate called without an active exception
with a core dump and a truncated result file.
Version
OMSimulator 3.0.0~154-g1c852587-linux-debug
OpenModelica 1.28.0~dev-284-g5fb7305
Ubuntu 24.04, x86_64
Why it came up
The OpenModelicaLibraryTesting scripts omit --stepSize when the experiment annotation gives no step size, precisely because passing 0 behaves this way (the guard is if stepSize != 0.0). A model whose StopTime equals its StartTime produces stepSize = 0, so a caller that passes the flag unconditionally hits this. Rejecting the value would make the guard unnecessary.
Generated by Claude Code.
--stepSize=0is accepted and then hangs (or aborts) instead of being rejectedWhat happens
Passing
--stepSize=0makes OMSimulator accept the value, printmaximum step size ... 0.000000, and then never finish. It writes a result file header and nothing else. On some FMUs it does not hang but aborts withpure virtual method calledand dumps core.A step size of zero cannot produce a simulation, so it seems better to reject it with a message than to accept it and stop making progress.
How to reproduce
The second command produces:
and then makes no further progress; killed after 60 s.
On an FMU generated from
ExternData.Examples.INITestthe same argument gives, instead of the hang:with a core dump and a truncated result file.
Version
Why it came up
The OpenModelicaLibraryTesting scripts omit
--stepSizewhen the experiment annotation gives no step size, precisely because passing0behaves this way (the guard isif stepSize != 0.0). A model whoseStopTimeequals itsStartTimeproducesstepSize = 0, so a caller that passes the flag unconditionally hits this. Rejecting the value would make the guard unnecessary.Generated by Claude Code.