防止MEX文件在MATLAB中崩溃 [英] Preventing a MEX file from crashing in MATLAB

查看:167
本文介绍了防止MEX文件在MATLAB中崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MEX文件,我从借从别人帮助我编码一个半自动核探测算法。问题是MEX文件偶尔导致分段故障。但是,如果代码第二次使用相同的参数运行,那就没问题了。

I have a MEX file which I "borrowed" from someone else to help me code a semi-automated nuclear detection algorithm. The problem is that the MEX file sporadically causes a segmentation fault. However, if the code is run with the same parameters a second time, it's fine.

我希望MEX文件有一种 try / catch 惯用法,星期六寻找的东西,我找不到任何东西。

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

这个问题的任何帮助将是惊人的!否则,我将不得不将 .cpp 移植到MATLAB中(约10,000行使用数百个依赖项: - ()。

Any help on this issue would be amazing! Otherwise, I am going to have to port the .cpp into MATLAB (and it's around 10,000 lines using hundreds of dependencies :-().

推荐答案

您使用哪个平台?有些方法可以帮助您对MEX文件进行调试每当出现分段错误时,

Which platform are you using? There are methods to help debug your MEX files. Whenever there is a segmentation fault, you can use an IDE to tell you where in the code it's crashing.

这里是Mac OS的路线: http://www.mathworks.com/help/matlab/matlab_external/debugging-on-mac-platforms.html

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

这里是Linux的路线: http://www.mathworks.com/help/matlab/matlab_external/debugging-on-linux-platforms.html

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

以下是Windows的路线: http://www.mathworks.com/help/matlab/matlab_external/debugging-on-microsoft-windows-platforms.html

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

NB 将OP提及站外链接以帮助他或她的问题。我通常包括我的帖子中的大部分答案,并提供链接作为参考。因为你没有告诉我你使用的平台,我不会为所有平台编写解决方案,因为这将需要太多的时间。因此(我祈祷的链接长期稳定),你可以参考适合你的平台的链接。

NB: I am against referring the OP to a link off-site to help with his or her question. I usually include most of the answer in my posts and provide links as references. Because you haven't told me what platform you're using, I will not write solutions for all platforms as that will take too much time. As such (and I'm praying that the links are stable for a long time), you can refer to the appropriate link for your platform.

这篇关于防止MEX文件在MATLAB中崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆