Incompatibilities between JVM and MEX?

3 ビュー (過去 30 日間)
Jesus
Jesus 2014 年 12 月 16 日
編集済み: Jesus 2014 年 12 月 16 日
I'm trying to create a MEX file which allows me to use a Robotics Toolkit libraries, MRPT, which has a quite big amount of dependencies as can be seen in http://www.mrpt.org/Building_and_Installing_Instructions. Namely, I'm using some classes which involve the use of drivers and read from an Hokuyo LIDAR. For that, I have also used mexplus (C++ MEX development kit) when creating the MEX files. Due to TLS problems with Matlab I compiled all MRPT libraries as static. Having done so, I encounter following situation when trying to use my MEX functions: - If I begin Matlab normally, and execute my MEX function Matlab crashes. - If I begin Matlab from terminal, with -nodesktop option, and execute my MEX functions from terminal, all works fine (it does not crash) - If I begin Matlab from terminal, with -nodesktop, then make some operation involving jvm such as plot(...), and later use my MEX functions, it does not immediately crash but after a random time, it will finally crash.
I don't understand what kind of incompatibility could arise from the use of Matlab and my libraries all together, or if it could be a bug related to graphics interface of Matlab.
Edit: I'm running on Linux, in Xubuntu 14.04
  2 件のコメント
Philip Borghesani
Philip Borghesani 2014 年 12 月 16 日
More background would be helpful. Are you running on Windows or Linux? What lead you to believe that a static library would solve TLS (Thread Local Storage? or Transport Layer Security?) problems?
Jesus
Jesus 2014 年 12 月 16 日
Sorry! I'm running on Linux, in Xubuntu 14.04 to be more precise. The issue with TLS was that I was first using my third libraries compiled as shared (.so), and Matlab returned some kind of error related to Thread Local Storage and DTV slots (I don't know much about it, I just read some related threads, as http://www.mathworks.com/matlabcentral/answers/125117-openmp-mex-files-static-tls-problem). So I tried to compile my third libraries as static (.a), and I got them finally working, although with the instability issue I already mentioned.

サインインしてコメントする。

採用された回答

Philip Borghesani
Philip Borghesani 2014 年 12 月 16 日
First guess is that one of the libraries you are using is installing a signal handler. Any third party signal handler is likely incompatible with Matlab's and will cause instability especially with the JVM.
Identify which library is doing it and disable it's signal handler.
  1 件のコメント
Jesus
Jesus 2014 年 12 月 16 日
In fact it has a signal handler! In the stack trace reported by Matlab after crashing it appears the line .../mexcamera_.mexa64+03892103 MRPT_SIGNAL_HANDLER_SIG+00000087 so if that causes instability that quite likely to be the source of the problem. Thank you very much! I will check it and tell here if it works.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by