Opened 15 years ago

Last modified 13 years ago

#1159 closed defect (fixed)

simulation runs old executable when compilation of model fails

Reported by: hkiel Owned by: hkiel
Priority: high Milestone:
Component: Version:
Keywords: Cc: hkiel, sjoelund.se

Description

I added an external "C" function which brings its own include.
When the compilation of the model fails because of a compile error *and* a previous executable exists, then the failure is not reported, instead the old executable will be run.

Attachments (3)

test.c (200 bytes) - added by hkiel 15 years ago.
{{{OpenModelica 1.5.0 Copyright (c) OSMC 2002-2009 To get help on using OMShell and OpenModelica, type "help()" and press enter. >> cd() "C:/OpenModelica1.5.0/tmp" >> system("gcc -c test.c") 0 >> loadFile("test.mo") true >> simulate(Motor, stopTime=1.0, numberOfIntervals=2000) record SimulationResult resultFile = "Motor_res.plt" end SimulationResult; edit test.h such that a compile error must occur (e.g. "int" -> "intx")[…]
test.h (37 bytes) - added by hkiel 15 years ago.
{{{OpenModelica 1.5.0 Copyright (c) OSMC 2002-2009 To get help on using OMShell and OpenModelica, type "help()" and press enter. >> cd() "C:/OpenModelica1.5.0/tmp" >> system("gcc -c test.c") 0 >> loadFile("test.mo") true >> simulate(Motor, stopTime=1.0, numberOfIntervals=2000) record SimulationResult resultFile = "Motor_res.plt" end SimulationResult; edit test.h such that a compile error must occur (e.g. "int" -> "intx")[…]
test.mo (1.3 KB) - added by hkiel 15 years ago.
{{{OpenModelica 1.5.0 Copyright (c) OSMC 2002-2009 To get help on using OMShell and OpenModelica, type "help()" and press enter. >> cd() "C:/OpenModelica1.5.0/tmp" >> system("gcc -c test.c") 0 >> loadFile("test.mo") true >> simulate(Motor, stopTime=1.0, numberOfIntervals=2000) record SimulationResult resultFile = "Motor_res.plt" end SimulationResult; edit test.h such that a compile error must occur (e.g. "int" -> "intx")[…]

Download all attachments as: .zip

Change History (10)

comment:1 Changed 15 years ago by sjoelund.se

Could you please attach (or e-mail) a sample mo and mos-file to reproduce this problem? I keep getting proper error messages in both Windows and Linux.

Changed 15 years ago by hkiel

{{{OpenModelica 1.5.0
Copyright (c) OSMC 2002-2009

To get help on using OMShell and OpenModelica, type "help()" and press enter.

cd()

"C:/OpenModelica1.5.0/tmp"

system("gcc -c test.c")

0

loadFile("test.mo")

true

simulate(Motor, stopTime=1.0, numberOfIntervals=2000)

record SimulationResult

resultFile = "Motor_res.plt"

end SimulationResult;

}}}
edit test.h such that a compile error must occur (e.g. "int" -> "intx")

>> simulate(Motor, stopTime=1.0, numberOfIntervals=2000)

record SimulationResult

    resultFile = "Motor_res.plt"

end SimulationResult;
 
>> }}}

comment:2 Changed 15 years ago by sjoelund.se

Still can't reproduce using the OpenModelica nightly build. This might be an issue with RC1, but if it's already fixed there's nothing we can do. Try the latest nightly build as it seems to work.

comment:4 Changed 15 years ago by hkiel

I tried the nightly 2010-01-28 on a different machine and I still get the problem.

I build the model from the attached files, get a working version, then introduce an error in test.h

loadFile("test.mo"); simulate(Motor)}}}

 and get a compile error (displayed in Motor.log), but the old Motor.exe is run again and simulation "works".

Mind you that I do not have OMDev installed, just the plain nightly.msi

comment:5 Changed 15 years ago by sjoelund.se

Yes, I'm starting to think the issue is that if you have OMDev installed, the compile script will now use the OMDev binaries instead of forcing the developer to copy the binaries to X places on the filesystem in order to get OpenModelica running everywhere.

comment:6 Changed 15 years ago by sjoelund.se

Or the issue is that your OPENMODELICAHOME is set to an older version of OpenModelica. For me, it worked even after removing OMDEV.

comment:7 Changed 15 years ago by hkiel

I tested the following on a "naked" winXp with OM 1.5.0 RC2 from OMShell:
{{{function func

output Integer value;
input Integer param;
external value = func(param) annotation(Library = "func.o", Include = "#include \"func.h\"");

end func;
model functest

Integer number(start=0);

equation

when sample(1,1) then

number = func(1);

end when;

end functest;}}}

The result is

0
0
0
record SimulationResult
    resultFile = "functest_res.plt"
end SimulationResult;
0
record SimulationResult
    resultFile = "functest_res.plt"
end SimulationResult;
0
record SimulationResult
    resultFile = "Simulation failed.
"
end SimulationResult;}}}

comment:8 Changed 15 years ago by hkiel

forgot to add the commands to execute:
{{{system("echo int func(int par){return 5;} > func.c");
system("echo extern int func(int par); > func.h");
system("gcc -c func.c -o func.o");
simulate(functest, stopTime=2);
system("echo extern xxx func(int par); > func.h");
simulate(functest, stopTime=2);
system("del functest.exe func.dll"); remove intermediate files
simulate(functest, stopTime=2)}}}

comment:9 Changed 13 years ago by sjoelund.se

We finally found the source of this bug after changing to Windows 7, where the bug does not appear. cmd.exe does not return non-zero exit status if /B is given to it. But only sometimes, and only on XP :)

Note: See TracTickets for help on using tickets.