Opened 5 years ago

Closed 5 years ago

#5557 closed discussion (fixed)

RT-Simulation failed due to getBestJumpBuffer() function

Reported by: Arinomo <trista.arinomo@…> Owned by: Lennart Ochel
Priority: blocker Milestone: 2.0.0
Component: FMI Version: v1.14.0-dev-nightly
Keywords: Cc: Andreas Heuermann, Niklas Worschech

Description

Tried to simulate a FMU that included a lookup table with external table. Text file was included in FMUroot/resources/... when exporting the model in OM.

Running it in a rt-simulation was unseccessful and from further de-bugging i've got

 #0 0x0808a123 in getBestJumpBuffer ()
 #1  0x0808a85d in va_throwStreamPrint ()
 #2  0x0808b722 in OpenModelica_Simulation_ModelicaVFormatError ()
 #3  0x0808b7c5 in ModelicaFormatError ()
 #4  0x080573dc in ModelicaIO_readRealTable ()
 #5  0x0805001e in ModelicaStandardTables_CombiTable1D_init2 ()
 #6  0x08092b9b in omc_Modelica_Blocks_Types_ExternalCombiTable1D_constructor ()
 #7  0x0809312e in FMUwithExternalTable_eqFunction_13 ()
 #8  0x0809358f in FMUwithExternalTable_updateBoundParameters_0 ()
 #9  0x080936e6 in FMUwithExternalTable_updateBoundParameters ()
 #10 0x08083ef4 in FMUwithExternalTable_fmi2ExitInitializationMode ()
 #11 0x080814bd in FMUwithExternalTable_DSFMUStartMdl ()
 #12 0x080807cd in ApSimEngineOnStart(DsCErrorListPool&) ()
 #13 0x08080c3c in DsCApplicationMain::onStart(DsCErrorListPool&) ()
 #14 0xb8544b60 in ?? ()

dSPACE support suggested the error is due to getBestJumpBuffer function.

I've looked into omc_error.c file to find a clue if some macro needs to be define/undefine as it a common fixed when implementing FMU from OM in dSPCACE environment, but still no solution found.

At the begining of omc_error.c there is a setjmp.h that being included but i seems can not found this h-file inside the FMU source file?

could the missing h-file that resulted in error? it's seems strange becaue when compiling the rt-application, there was no indication/error about missing h-file.

maybe someone has some pointer, would be much appriciated.

Change History (9)

comment:1 by Francesco Casella, 5 years ago

Cc: Andreas Heuermann Niklas Worschech added
Milestone: Future2.0.0

comment:2 by Andreas Heuermann, 5 years ago

At the begining of omc_error.c there is a setjmp.h that being included but i seems can not found this h-file inside the FMU source file?

could the missing h-file that resulted in error? it's seems strange becaue when compiling the rt-application, there was no indication/error about missing h-file.

setjmp.h is defined in the C standard library. I assume that's the reason why it's not included in the FMU source directory.

Maybe the header file you used in the dSPACE environment differs from the one we usally use from the C standard.

What exactly is your error when simulating?
Does the same error occures on a normal system (64bit something Windows/Linux) and could you provide a minimal example with such a lookup table?

comment:3 by Arinomo <trista.arinomo@…>, 5 years ago

Thank you for your reply,

could you provide a minimal example with such a lookup table?

below is the model i try to implement in real-time machine:

model FMUwithExternalTable
  import Load = mOdelica.Services.ExternalReferences.laodResource,
  input Boolean Trigger;
  output Real y;
  Modelica.Blocks.Tables.CombiTable1Ds Table(extrapoaltion = Modelica.Blocks.Types.Extrapolation.Periodic, fileName = Laod("modelica://Testpackage/ExternalTable.txt"=. smothness = Modelica.Blocks.Types.Smoothness.ConstantSegments, tableName = "Table", tableOnFile = true);
  Modelica.Blocks.Logical.Timer timer1;
equation
  connect(timer1.y,Table.u)
  if Trigger then
    timer1.u = true;
  else
    timer1.u = false;
  end if;
  y = Table.y[1]

What exactly is your error when simulating?

The error message that i've got is
HCN: Memory vilation exception! Real-time application (ID XXX) crashed due to an illegal memory access at address...

and on the stack trace mentioned above from dspace.

Does the same error occures on a normal system (64bit something Windows/Linux)

i have not test on any other real-time environment, but a check with fmuchecker on windows 10 64bit it unseucessfull due to #5431 and simulation in modelica was without any problem

Note: To enable sucessful compile of rt-application i have to set HAVE_MMAP=0, define DUMMY_FUNCTION_USERTAB macro and modify/commented-out some lines in the the ModeliccaStandardTablesUsertab.c due to undefined reference to usertab

#include "ModelicaUtilities.h"

#if defined(DUMMY_FUNCTION_USERTAB)
//#if (defined(__clang__) || defined(__GNUC__)) && !(defined(__apple_build_version__) || defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__))
int usertab(char* tableName, int nipo, int dim[], int* colWise,
            double** table) __attribute__ ((weak, alias ("dummy_usertab")));
#define USERTAB_NAME dummy_usertab
//#else
//#define USERTAB_NAME usertab
//#endif /* clang/gcc weak linking */
int USERTAB_NAME(char* tableName, int nipo, int dim[], int* colWise,
                 double** table) {
    ModelicaError("Function \"usertab\" is not implemented\n");
    return 1; /* Error */
}
#endif /* #if defined(DUMMY_FUNCTION_USERTAB) */

Another test case where i hard-coded the table inside the modelica model could be run in rt-machine with out any problem. So at leaset the combiTimeTable1Ds is working in dSPACE environment.

comment:4 by Francesco Casella, 5 years ago

Summary: RT-Simulation failed due to getBestJumpBuffer() funtionRT-Simulation failed due to getBestJumpBuffer() function

comment:5 by anonymous, 5 years ago

A follow-up question to above problem:

in omc_error.c the included setjmp header is written as #include "setjemp.h" as i mention above, this file is not included in the folder. So my question is, does compiler check the system library for said header file if there is none found in the same folder as the c-file?

@AnHeuermann

Maybe the header file you used in the dSPACE environment differs from the one we usally use from the C standard.

which setjmp.h is used by default by OM? is it the one in ...\mysys\mingw64\x86_64-w64-mingw32\include\... or ..\mysys\usr\include\...

in reply to:  2 comment:6 by Trista Arinomo <trista.arinomo@…>, 5 years ago

Replying to AnHeuermann:

What exactly is your error when simulating?

Hallo AnHeuermann,

bellow are some relevant error messages i got when trying to run the rt-application:

ControlDesk HiBord:	Severe Error	2019/07/05 09:59:24.898	6,1803: HCN: Memory violation exception! Real-time application (ID 0x00813682) crashed due to an illegal memory access at address 0x00000064. Execution stopped at address 0x08089bf3 near symbol 'Application_00813682.x86@_btext+0x3fa93'. [3,4952E-05] (0x4,2852)
ControlDesk HiBord:	Info	2019/07/05 09:59:24.898	6,1803: HCN: stdout            |  [646,6825579475] (0x4,2852)
ControlDesk HiBord:	Info	2019/07/05 09:59:24.898	6,1803: HCN: info    |  [646,6825672805] (0x4,2852)
ControlDesk HiBord:	Info	2019/07/05 09:59:24.898	6,1803: HCN: ... loading "Table" from "/exchange/local/FmuResources/FMUwithExternalTable/D:\2030_OpenModelica_Trista\Models\TestPackage\ExternalTable.txt" [646,68257074] (0x4,2852)
ControlDesk HiBord:	Info	2019/07/05 09:59:24.898	6,1803: HCN: assert            |  [646,682635544] (0x4,2852)
ControlDesk HiBord:	Info	2019/07/05 09:59:24.898	6,1803: HCN: debug   |  [646,682639165] (0x4,2852)
ControlDesk HiBord:	Info	2019/07/05 09:59:24.899	6,1803: HCN: Not possible to open file "/exchange/local/FmuResources/FMUwithExternalTable/D:\2030_OpenModelica_Trista\Models\TestPackage\ExternalTable.txt": No such file or directory [646,6826420975] (0x4,2852)
ControlDesk HiBord:	Error	2019/07/05 09:59:24.899	6,1803: Application process crashed. Check message log for error reports. dSPACE Support information: Application ID: 0x813682. [646,732509532] (0x4,2852)
ControlDesk HiBord:	Info	2019/07/05 09:59:24.899	6,1803: Application terminated (0x813682). [646,732535168] (0x4,2852)

Could it be that because the text file could not be found that resulting in a memorry error exception?

ControlDesk HiBord:	Info	2019/07/05 09:59:24.899	6,1803: HCN: Not possible to open file "/exchange/local/FmuResources/FMUwithExternalTable/D:\2030_OpenModelica_Trista\Models\TestPackage\ExternalTable.txt": No such file or directory [646,6826420975] (0x4,2852)

Because as expalined in #5431, the path symbol is mixed between / and \.

Cheers
A

comment:7 by Adrian Pop, 5 years ago

If the table cannot be opened I think an assertion is triggered and a longjmp is attempted in OpenModelica_Simulation_ModelicaVFormatError via va_throwStreamPrint. The longjmp is tried because in some cases we need to be able to ignore an assert and continue (solving NLS systems, etc). I think it will work fine if the fixes for #5431 are OK.

in reply to:  7 comment:8 by Trista Arinomo <trista.arinomo@…>, 5 years ago

Replying to adrpo:

If the table cannot be opened I think an assertion is triggered and a longjmp is attempted in OpenModelica_Simulation_ModelicaVFormatError via va_throwStreamPrint. The longjmp is tried because in some cases we need to be able to ignore an assert and continue (solving NLS systems, etc). I think it will work fine if the fixes for #5431 are OK.

Hi Adrian,

thank you once agian for the fix. I tried a simple combilTimeTable with an external txt file on dSPACE system and now it works as expected. So i will close the ticket.

comment:9 by Trista Arinomo <trista.arinomo@…>, 5 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.