Preventing a MEX File Crash in MATLAB

I have a MEX file that I “borrowed” from someone else to help me code a semi-automatic kernel detection algorithm. The problem is that the MEX file sporadically causes a segmentation error. However, if the code is run with the same parameters a second time, this is normal.

I was hoping there was a kind of try/catchidiom for MEX files , but after spending most of my Saturday looking for something, I couldn't find anything.

Any help on this would be awesome! Otherwise, I have to wrap .cppin MATLAB (and that's about 10,000 lines, using hundreds of dependencies: - ().

+1
source share
1 answer

What platform are you using? There are methods to debug MEX files. Whenever a segmentation error occurs, you can use the IDE to tell you where in the code that it is failing.

Here are the instructions for Mac OS: http://www.mathworks.com/help/matlab/matlab_external/debugging-on-mac-platforms.html

Here are the instructions for Linux: http://www.mathworks.com/help/matlab/matlab_external/debugging-on-linux-platforms.html

Here are the instructions for Windows: http://www.mathworks.com/help/matlab/matlab_external/debugging-on-microsoft-windows-platforms.html

NB: OP , . . , , , . ( , ), .

+3

Source: https://habr.com/ru/post/1547961/


All Articles