A very strange exception when running a mex file - "a corruption of the heap, which indicates a bug in MATLAB.exe"

7 次查看(过去 30 天)
Hi,
I'm running a mex file in Matlab while debugging it in Visual Studio 2010. I mean that I'm running it in Matlab and when the m file reaches the call to the mex file, the focus automatically switches to VS and it stops in a break point i defined.
While I continue running in VS, I get the following message:
"Windows has triggered a breakpoint in MATLAB.exe.
This may be due to a corruption of the heap, which indicates a bug in MATLAB.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while MATLAB.exe has focus.
The output window may have more diagnostic information."
Immediately after that, I get the following message: Unhandled exception at 0x77a240f2 in MATLAB.exe: 0xC0000374: Corrupted heap (the exact message is in Hebrew, I translated it to English).
Well, I haven't got the slightest clue as to how to debug it. It doesn't necessarily happen in the same place every time. Does anyone know what it means? What went wrong?
Thanks in advance,
Gil.
  5 个评论
Colin
Colin 2013-1-23
Hi Gil,
Do you use C++ or Fortran?
I get almost the same message. I use Intel Fortran Compiler with Visual Studio 2010.
The strange thing is, that I can run the mexfunction one time. If I run it again, I get that error.

请先登录,再进行评论。

回答(1 个)

Colin
Colin 2013-1-24
As I wrote in the comment, I got the same error. After a step by step commenting out of code I found the error.
I called the function
mxSetField(OPD,INDEX,'HAMILTON',OP2)
without initializing the field 'HAMILTON' in
mxCreateStructMatrix()
or with
mxAddField()
correctly. Maybe this will help you finding the error.

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by