Skip to content

--stepSize=0 is accepted and then hangs (or aborts) instead of being rejected #1622

Description

@adrpo

--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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions