OpenModelica icon indicating copy to clipboard operation
OpenModelica copied to clipboard

ExternData hangs omc on Windows

Open casella opened this issue 1 year ago • 3 comments

The testing of ExternData under Linux is successful, except for one example that we should probably look into.

If you run them under Windows, omc hangs indefinitely. We have a user reporting that this has been going on at least since 1.23.0. I'm not really sure exactly where it hangs, if I just instantiate the model all's fine, so it's probably not the frontend. Unfortunately -d=execstat doesn't give any output.

What is weird is that if I have real-time anti-malware protection, it goes on engaging 20-40% of my 8-core CPU for a very long time. If I disable that, very soon omc.exe goes to 0% CPU and stays like that indefinitely.

@arun3688, could you try to debug this and figure out what is going wrong? Thanks!

casella avatar Oct 09 '24 14:10 casella

Unfortunately -d=execstat doesn't give any output.

You can probably see how far it gets if you also use --showErrorMessages, it'll print out messages when they are emitted instead of only at the end of the compilation.

perost avatar Oct 09 '24 15:10 perost

I did it, and this is what I get

...
Notification: Performance of postOpt removeConstants (simulation): time 4.68e-005/0.05707, allocations: 96.98 kB / 431.6 MB, free: 5.965 MB / 347.4 MB
Notification: Performance of postOpt simplifyTimeIndepFuncCalls (simulation): time 4.24e-005/0.05711, allocations: 4 kB / 431.6 MB, free: 5.961 MB / 347.4 MB
Notification: Performance of postOpt simplifyAllExpressions (simulation): time 5.98e-005/0.05717, allocations: 4 kB / 431.6 MB, free: 5.957 MB / 347.4 MB
Notification: Performance of postOpt findZeroCrossings (simulation): time 3.36e-005/0.05721, allocations: 15.98 kB / 431.6 MB, free: 5.941 MB / 347.4 MB
Notification: Performance of postOpt collapseArrayExpressions (simulation): time 1.34e-005/0.05722, allocations: 8 kB / 431.7 MB, free: 5.934 MB / 347.4 MB
Notification: Performance of sorting global known variables: time 0.0001059/0.05733, allocations: 111.2 kB / 431.8 MB, free: 5.824 MB / 347.4 MB
Notification: Performance of sort global known variables: time 1e-007/0.05733, allocations: 0 / 431.8 MB, free: 5.824 MB / 347.4 MB
Notification: Performance of remove unused functions: time 0.000239/0.05757, allocations: 75.8 kB / 431.8 MB, free: 5.75 MB / 347.4 MB
[C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/package.mo:129:23-129:184:writable] Notification: Created directory C:/Users/FRANCE~1/AppData/Local/Temp//omc_compile_ED_JSONFile_174094
[C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/package.mo:129:23-129:184:writable] Notification: cp -a \"C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources\"/* \"C:/Users/FRANCE~1/AppData/Local/Temp//omc_compile_ED_JSONFile_174094\"
[C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/package.mo:129:23-129:184:writable] Notification: Changed directory to C:/Users/FRANCE~1/AppData/Local/Temp/omc_compile_ED_JSONFile_174094/BuildProjects/autotools
[C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/package.mo:129:23-129:184:writable] Warning: Failed to run sh ./autogen.sh && ./configure --libdir='C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/binaries/ExternData' && make && make install:
\".\" non è riconosciuto come comando interno o esterno, un programma eseguibile o un file batch.
[C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/package.mo:129:23-129:184:writable] Notification: Removed directory C:/Users/FRANCE~1/AppData/Local/Temp//omc_compile_ED_JSONFile_174094
[C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/package.mo:129:23-129:184:writable] Warning: Could not find library ED_JSONFile in either of:
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/lib//omc/ED_JSONFile.dll
  /usr/lib//ED_JSONFile.dll
  /lib//ED_JSONFile.dll
  /usr/lib//ED_JSONFile.dll
  /lib//ED_JSONFile.dll
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/bin//ED_JSONFile.dll
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/lib//omc/ED_JSONFile.dll
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/lib//ED_JSONFile.dll
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/binaries/ExternData/ED_JSONFile.dll
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources/Library/ucrt64/ED_JSONFile.dll
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources/Library/win64/ED_JSONFile.dll
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources/Library/ED_JSONFile.dll
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/lib//omc/libED_JSONFile.a
  /usr/lib//libED_JSONFile.a
  /lib//libED_JSONFile.a
  /usr/lib//libED_JSONFile.a
  /lib//libED_JSONFile.a
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/bin//libED_JSONFile.a
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/lib//omc/libED_JSONFile.a
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/lib//libED_JSONFile.a
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/binaries/ExternData/libED_JSONFile.a
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources/Library/ucrt64/libED_JSONFile.a
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources/Library/win64/libED_JSONFile.a
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources/Library/libED_JSONFile.a
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/lib//omc/libED_JSONFile.lib
  /usr/lib//libED_JSONFile.lib
  /lib//libED_JSONFile.lib
  /usr/lib//libED_JSONFile.lib
  /lib//libED_JSONFile.lib
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/bin//libED_JSONFile.lib
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/lib//omc/libED_JSONFile.lib
  C:/Program Files/OpenModelica1.24.0-dev.beta.0-64bit/lib//libED_JSONFile.lib
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/binaries/ExternData/libED_JSONFile.lib
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources/Library/ucrt64/libED_JSONFile.lib
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources/Library/win64/libED_JSONFile.lib
  C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources/Library/libED_JSONFile.lib
[C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/package.mo:129:23-129:184:writable] Notification: Created directory C:/Users/FRANCE~1/AppData/Local/Temp//omc_compile_parson_171152
[C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/package.mo:129:23-129:184:writable] Notification: cp -a \"C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources\"/* \"C:/Users/FRANCE~1/AppData/Local/Temp//omc_compile_parson_171152\"
[C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/package.mo:129:23-129:184:writable] Notification: Changed directory to C:/Users/FRANCE~1/AppData/Local/Temp/omc_compile_parson_171152/BuildProjects/autotools
[C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/package.mo:129:23-129:184:writable] Warning: Failed to run sh ./autogen.sh && ./configure --libdir='C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/binaries/ExternData' && make && make install:
\".\" non è riconosciuto come comando interno o esterno, un programma eseguibile o un file batch.
[...

Apologies for the Italian version of the Windows error messages, it roughly means "." is not recognized as an internal or external command, an executable program or a batch file.

These errors takes place multiple times at the boundary between Backend and SimCode. It seems that the library wants to make some stuff at compile time but has some trouble running the shell command to do so because of syntax issues or something. BTW, every time this happens, the anti-malware runs for several seconds trying to identify malicious code being run on the computer.

@perost, @arun3688 could you please have a look and figure out exactly what is going wrong?

casella avatar Oct 10 '24 12:10 casella

Rescheduled to 1.24.3, we have to proceed with 1.24.2 ASAP.

casella avatar Nov 14 '24 13:11 casella

This calls ExternData\Resources\BuildProjects\autotools to build the C library archives, fails and calls it again, forever.

adrpo avatar Jun 24 '25 17:06 adrpo

Is it reasonable to have C compilation on demand in external functions? Shouldn't libraries be compiled at release time?

casella avatar Jun 24 '25 20:06 casella

This is not that. This is just to automatically build the external C code in the library when we don't detect them. This should never happen in this case as the libraries are built and available at Resources/Library/mingw64.

adrpo avatar Jun 24 '25 20:06 adrpo

Ah, nevermind, I didn't get your question at first. Is good to be able to build the lib on first usage on the fly if possible on that particular computer and OM version.

adrpo avatar Jun 24 '25 20:06 adrpo

As long as it doesn't get into an infinite loop, that is 😆

casella avatar Jun 24 '25 20:06 casella

For now to make it not go into an infinite loop one needs to add translation flag: -d=-buildExternalLibs. That will disable the autotools build of the library C-resources.

adrpo avatar Jul 22 '25 09:07 adrpo

The library also provides Library/mingw64 but we have switched from that to ucrt64 since some time now. I wonder if we could use the mingw64 libraries with our ucrt64 compiled model source code or we would need to build our own ucrt64 version. I will do some checks.

One can see what happens here, we only include ucrt64 and win64 directories, I think we need to add also a line with mingw64 in between:

C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources/Library/ucrt64/libED_JSONFile.a
C:/Users/Francesco Casella/AppData/Roaming/.openmodelica/libraries/ExternData 3.0.5/Resources/Library/win64/libED_JSONFile.a

adrpo avatar Jul 22 '25 09:07 adrpo

This is partially fixed now but I will keep this open until I fix it properly with a full check of the success of autotools build call.

adrpo avatar Jul 22 '25 13:07 adrpo