modelon-community / fmi-library

C library for importing FMUs
Other
110 stars 35 forks source link

"Segmentation fault (core dumped) " error happend, when I try to run a FMU #132

Closed lyw2024 closed 1 month ago

lyw2024 commented 1 month ago

Hello, all: after I have install the FMI-libray (verison is 3.0a4). Then I have run the file "fmi2_import_cs_test.c", this can be success. but if I try to run the FMU I build in simulink with the same file(in order to run the FMU I build, I have do some adapt in the code of fmi2_import_cs_test). then one error happened.

lyw@ubuntu:~/Desktop/fmi-library-master/fmi-library-master/Test/FMI2$ ./fmi2_import_cs_test module = FMILIB, log level = VERBOSE: Allocating FMIL context module = FMILIB, log level = VERBOSE: Detecting FMI standard version module = FMIZIP, log level = VERBOSE: Unpacking FMU into /home/lyw/Desktop/fmi-library-master/fmi-library-master/build_fmi/Testing/FmuUnpack/fmilET6DT6 module = FMIXML, log level = VERBOSE: Parsing XML to detect FMI standard version module = FMIXML, log level = VERBOSE: XML specifies FMI 2.0 module = FMILIB, log level = INFO: XML specifies FMI standard version 2.0 module = FMILIB, log level = VERBOSE: Parsing model description XML module = FMI2XML, log level = VERBOSE: Parsing XML element fmiModelDescription module = FMI2XML, log level = VERBOSE: Parsing XML element CoSimulation module = FMI2XML, log level = VERBOSE: Parsing XML element VendorAnnotations module = FMI2XML, log level = VERBOSE: Parsing XML element ModelVariables module = FMI2XML, log level = VERBOSE: Building alias index module = FMI2XML, log level = VERBOSE: Parsing XML element ModelStructure module = FMI2XML, log level = VERBOSE: Parsing XML element Outputs module = FMI2XML, log level = VERBOSE: Parsing XML element InitialUnknowns module = FMILIB, log level = VERBOSE: Parsing finished successfully module = FMILIB, log level = INFO: Loading 'linux64' binary with 'default' platform types module = FMICAPI, log level = VERBOSE: Loaded FMU binary from /home/lyw/Desktop/fmi-library-master/fmi-library-master/build_fmi/Testing/FmuUnpack/fmilET6DT6/binaries/linux64/Demo.so module = FMICAPI, log level = VERBOSE: Loading functions for the co-simulation interface module = FMILIB, log level = VERBOSE: Successfully loaded all the interface functions Version returned from FMU: 2.0 module = FMICAPI, log level = VERBOSE: Calling fmi2GetModelTypesPlatform Platform type returned: default GUID: {c76c9f26-5fe5-ee9c-87ca-d2d15aff7130} module = FMICAPI, log level = VERBOSE: Calling fmi2SetupExperiment module = FMICAPI, log level = VERBOSE: Calling fmi2EnterInitializationMode module = FMICAPI, log level = VERBOSE: Calling fmi2ExitInitializationMode Ball height Ball speed module = Test CS model instance, log level = INFO: [info][FMU status:OK] CommunicationStepSize=0.001, LocalSolverStepSize=0.001 module = Test CS model instance, log level = INFO: [info][FMU status:OK] Local solver will do 1 steps from t = 0. Segmentation fault (core dumped)

do you know this error will happend?

thank you.

PeterMeisrimelModelon commented 1 month ago

Hi lyw2024,

the segmentation fault appears to occur within the doStepcall and this would then be a question for the FMU generating tool. I'd also suggest to try with gdb to see if the segmentation fault is indeed within the FMU.

/Peter

lyw2024 commented 1 month ago

hello, peter: yes. this error happened when call dostep function. my FMU is generated with simuink. but for the same soucre code, if I generate for windows platfrom, this FMU can run. but for linux, it tells me that " Segmentation fault (core dumped)" error happened. can you give me some advice to check this issues? I have updated the source code. sourcescode.zip

PeterMeisrimelModelon commented 1 month ago

Hi lyw2024,

anything happening inside the FMU is a question for the FMU generating tool, i.e., simulink in this case. I'd suggest to check with them. Also, just to make sure: The issue with the linux FMU occurs when using a linux machine?

/Peter

lyw2024 commented 1 month ago

Hello, peter: I just run with the same FMU in NI-veristand realtime machine. the OS of this realtime machine also is Linux. I import the FMU to NI veristand, and it can work. no error happend. so maybe this is not FMU issue.

PeterMeisrimelModelon commented 1 month ago

But if the segmentation fault occurs within the doStep function, it is within the FMU. For FMI CAPI calls, FMILibrary is primarily just providing a convenient API ( + some sanity checks).

/Peter

lyw2024 commented 1 month ago

hello, peter: this issue is fixed after I set the callbackfunctions to NULL. image