A very strange exception when running a mex file - "a corruption of the heap, which indicates a bug in MATLAB.exe"
7 views (last 30 days)
Show older comments
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 Comments
Colin
on 23 Jan 2013
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.
Stéphanie Monteiro
on 30 Jan 2022
Hello,
I'm having the same error. How can you solved this?
Thanks!!!
Answers (1)
Colin
on 24 Jan 2013
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.
0 Comments
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!