フィルターのクリア

Segmentation fault calling compiled shared library Initialize routine

14 ビュー (過去 30 日間)
Mark Almquist
Mark Almquist 2023 年 7 月 23 日
回答済み: Mark Almquist 2023 年 8 月 7 日
I have a compiled C++ Matlab shared library (libXXXLibrary.so) that I've been testing. When I used mbuild to build a driver app for testing the library's functionality, everything works. I then created an external "toy" .cpp driver, which sucessfully builds and links.
When I compile the app for release, everything works fine. But if I build for debug, I get a segmentation fault when the Matlab compiler generated libXXXLibraryInitialize() is called. If I attempt to bypass this by calling mclmcrInitialize() directly, I get a crash dump.
Any suggestions on how to approach this problem?

回答 (2 件)

Pratyush
Pratyush 2023 年 7 月 26 日
編集済み: Pratyush 2023 年 7 月 26 日
Hi Mark,
I understand that you face the issue when the gdb is attached while running the C++ application. The problem occurs in debug mode and not in release mode when directly using mbuild workflow in the MATLAB environment.
The cause of this problem may be incompatibility between JRE of MATLAB and the gdb (gcc debugger).
The segmentation fault might be occuring due to this incompatibility.
The workaround is to disable the Java RTE from MATLAB in the C++ application by specifying the options array as explained in the following post: How do I use the mclInitializeApplication function to make a C-shared library that does not use the JVM or JIT in MATLAB 7.0 ... - MATLAB Answers - MATLAB Central (mathworks.com)

Mark Almquist
Mark Almquist 2023 年 8 月 7 日
The answer to use "-nojvm","-nojit" works fine if the C++ function calls I make into the compiled C++ Matlab shared library (both debug and release builds) do not involve generating figures. If the called Matlab function generates graphics/figures, the application crashes.
mark a.

カテゴリ

Help Center および File ExchangeC Shared Library Integration についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by