xcosDiagramToScilab statement deeply unstable and crashes Scilab 6 session
@perrichonpierre58)
Reported by pierre perrichon (BUG DESCRIPTION:
----------------
xcosDiagramToScilab statement deeply unstable and crashes Scilab 6 session
I wrote, some time ago, a GUI named OPTSIM, to compute parameters of a speed governor in an hydraulic context power plants
The main page of this GUI is in attached file OptSim - Main Page.pdf.
This program loads Xcos models, as asked by several universities, instead of litteral programs in Scilab language
This program has been developped with Scilab 5.5.2, run perfectly and is very robust
The same program crashes Scilab time to time when running with with Scilab 6.1.1.
After study and analysis of the problem , the cause of the crash is around the sequence which load zcos model into scilab, using importXcosDiagram statement,
so it means xcosDiagramToScilab inside importXcosDiagram.sci routine.
In this aim, I here provide a short program "Bug_xcosDiagramToScilab.sce" to highlight this aleatory bug.
Main instrctions come from the lincos example (help lincos to access them) and are also used in OPTSIM.
This is mainly an iteration of importXcosDiagram (1000 calls)
This same program can be run under Scilab 5.5.2 and 6.1.1.
File FTBO - Scilab 5.5.2.zcos, in attached file, is the load model when using scilab 5.5.2
File FTBO - Scilab 6.1.1.zcos, in attached file, is the load model when using scilab 6.1.1
Using Scilab 5.5.2, this program is robust and never crash
It crashes with Scilab 6.1.1 at iteration n°8 or 48 or 50 or 127 or ... aleatory.
Important note: In this program, there are tests using the "scs_m" structure.
Following my study and tests, crashes are less frequent if "scs_m" instructions are by-pass.
This is the reason while I introduce a variable "by_pass" to be set in the test program to by-pass or not the "scs_m" instrctions.
Note : Models don't have SUPER BLOCK (SUPER_f)
When the program crashes (scilab 6.1.1), there also are, from time to time, error files created, as hs_err_pid11884.log for example.
Here is my test program "Bug_xcosDiagramToScilab.sce", also provided in attached file
//---------------------------------------------------------------------------------------------------------------------------------------------------
clc
by_pass=0 // by pass (1) or not (0) scs_m instructions in the loop
version_numbers = getversion('scilab');
VersionScilab=version_numbers(1)
Root = get_absolute_file_path("Bug_xcosDiagramToScilab.sce")
if VersionScilab<6 then
ModeleFTBO="FTBO - Scilab 5.5.2.zcos"
else
ModeleFTBO="FTBO - Scilab 6.1.1.zcos"
end
Modele=Root + ModeleFTBO
disp("Model XCOS :", Modele)
mprintf("\nby_pass=%i\n\n", by_pass)
// Paramètres du Modèle
Kp = 1.34; Ti = 15.32; Td = 1.1; Kd = 10
Tw = 3.54; Ta = 11.93; rho = 1.32; k = 0.73; Ts = 0.25; aut = 0; Gain = 1; ty = 0.1; Tau=2;
tic()
for k=1:1000 // Loop
try
if modulo(k,50)==0 | k<101 then
mprintf("k=%i\n",k)
end
loadXcosLibs(); loadScicos();
res=importXcosDiagram(Modele); // Répertoire+ Fichier
//----------------------------------------------------------------------------------------------------
// Looking for the Superblock to linearize
// Récupération des objets du schéma
// Prototype : entrer "help lincos" dans la console Scilab
//----------------------------------------------------------------------------------------------------
if ~by_pass then
for i=1:length(scs_m.objs)
if typeof(scs_m.objs(i))=="Block" & scs_m.objs(i).gui=="SUPER_f" then
scs_m = scs_m.objs(i).model.rpar;
break;
end
end
end
catch
error(lasterror()); break
end
end
mprintf("\nTemps écoulé : %0.3f\n\n", toc())
disp("scs_m:", scs_m)
ERROR LOG:
----------
See for example, in attached files :
- hs_err_pid11884.log
- hs_err_pid3668.log
HOW TO REPRODUCE THE BUG:
-------------------------
Load attached file in a new working directory abd run "Bug_xcosDiagramToScilab.sce"
1) with scilab 5.5.2
2) with scilab 6.1.1
OTHER INFORMATION:
------------------
Edited by scilab bot