Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation error of FAST v8-Simulink using the compiled FAST_SFunc mex file in Linux #567

Closed
yichaoliu629 opened this issue Oct 14, 2020 · 4 comments

Comments

@yichaoliu629
Copy link

yichaoliu629 commented Oct 14, 2020

Dear all,

As suggested by Jason, I come here to ask for your help.
I am using FAST v8. I was trying to recompile the FAST library and FAST_SFunc Mex file in the Linux system (CentOs 7), in order to run FAST v8-Simulink. By the way I commented out the line 173 of FAST_SFunc.c following this answer viewtopic.php?t=1387 when I created the mex file. The compilation tool is gcc 6.3. The build log of mex file is here:
mex_build.log
Also, I got some warnings when I compiled the FAST_library. The build log has been attached.
build.log

I got both of them successfully in the bin folder: libFAST_Library_glin64.so and FAST_SFunc.mexa64. When I run the S-function in Simulink, Matlab got crashed and I received this segmentation error. I double-checked the compilation of the FAST Library and mex file. I don't know how to deal with this? Can you help me? Thank you so much!

The segmentation error is like this:

error_page1
error_page2

@yichaoliu629 yichaoliu629 changed the title segmentation error of FAST-Simulink using the compiled FAST_SFunc mex file in Linux segmentation error of FAST v8-Simulink using the compiled FAST_SFunc mex file in Linux Oct 14, 2020
@yichaoliu629 yichaoliu629 changed the title segmentation error of FAST v8-Simulink using the compiled FAST_SFunc mex file in Linux Segmentation error of FAST v8-Simulink using the compiled FAST_SFunc mex file in Linux Oct 14, 2020
@bjonkman
Copy link
Contributor

Which version of OpenFAST are you using? We recently fixed a bug that would cause a segmentation fault like this.

You can either modify the code as explained in this issue: #548 (comment)
Or, you can get the latest version of the OpenFAST dev branch (with pull request #550 merged in).

@yichaoliu629
Copy link
Author

Which version of OpenFAST are you using? We recently fixed a bug that would cause a segmentation fault like this.

You can either modify the code as explained in this issue: #548 (comment)
Or, you can get the latest version of the OpenFAST dev branch (with pull request #550 merged in).

Dear Bonnie,

Thank you for your prompt help! I am using a FAST v8, instead of the OpenFAST. It might be the version published in 2016 (FAST_v8.16.00a-bjj).

@bjonkman
Copy link
Contributor

It's a little harder to debug something from FAST v8 because it's been a while since I've looked at that code. Your segmentation fault says it's coming from the EqualRealNos routine, but that gets called a lot. If you can put some print statements in the FAST source file, you might be able to pinpoint where it is in the code, and that may help.

Segmentation faults typically come because the code is accessing memory that it shouldn't be; that can be caused by sending arrays that are too small between the Fortran (FAST) and C (Simulink) interface, or an index getting set improperly, or arrays not getting allocated before they are used, etc.

If you can build and run FAST v8 with the same model you are using here without getting this error, that would point to a problem in the interface (something incompatible in FAST_Library.f90, FAST_Library,h and FAST_SFunc.c).

@yichaoliu629
Copy link
Author

yichaoliu629 commented Oct 14, 2020

Dear Bonnie,

I didn't change anything about the source code of FAST v8. This FAST model is working very well both in FAST standard-alone and FAST-Simulink in Windows. I am trying to make a Linux version. I also compiled the standard version of FAST v8 in Linux. It is working well.
This issue only appears when I run it on Simulink with a shared FAST library and mex file in Linux. So I agree it should be something about the interface. But I didn't find EqualRealNos called in FAST_Library.f90, FAST_Library,h, and FAST_SFunc.c. So I don't know how to check these three files. Any further suggestions would be really appreciated.

And also it looks it ony get crashed when running mex file which linked to servoDyn module, see screenshot:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants