MATLAB Answers

2

How do I identify the MEX function that caused MATLAB to crash?

Asked by MathWorks Support Team on 15 Apr 2015
Latest activity Answered by L A
on 6 Sep 2018
MATLAB crashed when I tried running my code, and I believe the cause of the crash was a custom MEX function I may be using. 
 
How can I determine from the following MATLAB crash log which MEX function caused the crash?
 
------------------------------------------------------------------------
          Access violation detected at Tue Feb 17 11:01:07 2015
------------------------------------------------------------------------
 
Configuration:
  Crash Decoding     : Disabled
  Default Encoding   : windows-1252
  Graphics card 1    : Intel Corporation ( 0x8086 ) Intel® HD Graphics 650 Version 9.17.10.3347
  MATLAB Architecture: win64
  MATLAB Root        : C:\Program Files\MATLAB\R2014b
  MATLAB Version     : 8.4.0.150421 (R2014b)
  Operating System   : Microsoft Windows 8.1 Pro
  Processor ID       : x86 Family 6 Model 42 Stepping 7, GenuineIntel
  Software OpenGL    :0
  Virtual Machine    : Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot™ 64-Bit Server VM mixed mode
  Window System      : Version 6.3 (Build 9600)
 
Fault Count: 1
 
 
Abnormal termination:
Access violation
 
Register State (from fault):
  RAX = 00000000a9703e40  RBX = 000000009f363920
  RCX = 00000000a93b8220  RDX = 46e267db0eeca3e7
  RSP = 0000000004035960  RBP = 0000000000000000
  RSI = 000000009f9be290  RDI = 000000009f363910
 
   R8 = 000000009f363920   R9 = 0000000000077a60
  R10 = 0000000000000000  R11 = 0000000004035930
  R12 = 0000000000000000  R13 = 000000007c9ba1a0
  R14 = 00000000000000a3  R15 = 8000460003491dce
 
  RIP = 00007ffc13bc1371  EFL = 00010a06
 
   CS = 0033   FS = 0053   GS = 002b
 
Stack Trace (from fault):
[  0] 0x00007ffc13bc1371                      C:\Windows\SYSTEM32\ntdll.dll+00201585 RtlFreeHeap+00000209
[  1] 0x000000005c668d94 C:\Program Files\MATLAB\R2014b\bin\win64\MSVCR100.dll+00429460 free+00000028
[  2] 0x00007ffc074b12b7 C:\Segmentation\cvtColor.mexw64+00004791 mexFunction+00000423
[  3] 0x00000000fc5f3701 C:\Program Files\MATLAB\R2014b\bin\win64\libmex.dll+00079617 mexRunMexFile+00000129
[  4] 0x00000000fc5f2762 C:\Program Files\MATLAB\R2014b\bin\win64\libmex.dll+00075618 inSwapMexfileReader+00000690
[  5] 0x00000000fc5f2248 C:\Program Files\MATLAB\R2014b\bin\win64\libmex.dll+00074312 mexUnlock+00006008
[  6] 0x0000000004ad05e3 C:\Program Files\MATLAB\R2014b\bin\win64\m_dispatcher.dll+00067043 Mfh_file::dispatch_fh+00000659
[  7] 0x0000000004ad0aee C:\Program Files\MATLAB\R2014b\bin\win64\m_dispatcher.dll+00068334 Mfunction_handle::dispatch+00000766
[  8] 0x0000000004e8b606 C:\Program Files\MATLAB\R2014b\bin\win64\m_interpreter.dll+00112134 MathWorks::MException::IMExceptionData::IMExceptionData+00037094
[  9] 0x0000000004e8aa20 C:\Program Files\MATLAB\R2014b\bin\win64\m_interpreter.dll+00109088 MathWorks::MException::IMExceptionData::IMExceptionData+00034048
[ 10] 0x0000000004e89219 C:\Program Files\MATLAB\R2014b\bin\win64\m_interpreter.dll+00102937 MathWorks::MException::IMExceptionData::IMExceptionData+00027897
[ 11] 0x0000000004e88de5 C:\Program Files\MATLAB\R2014b\bin\win64\m_interpreter.dll+00101861 MathWorks::MException::IMExceptionData::IMExceptionData+00026821
[ 12] 0x0000000004edb708 C:\Program Files\MATLAB\R2014b\bin\win64\m_interpreter.dll+00440072 inPathNotification::function_delete_notification+00128952
...

2 Answers

Answer by MathWorks Support Team on 15 Apr 2015
 Accepted Answer

The "mexRunMexFile" function is the one that calls the custom MEX function.  First, find the frame line that contains the "mexRunMexFile" keyword from the "Stack Trace" section:
 
[  3] 0x00000000fc5f3701 C:\Program Files\MATLAB\R2014b\bin\win64\libmex.dll+00079617 mexRunMexFile+00000129
 
The frame line above it is the custom MEX function that caused the crash:
 
[  2] 0x00007ffc074b12b7 C:\Segmentation\cvtColor.mexw64+00004791 mexFunction+00000423
 
In this case, the "cvtColor.mexw64" MEX function from the "Segmentation" program appears to be the one that caused MATLAB to crash. 
If you are not the author of this MEX function, you may want to contact the author for help in troubleshooting this MATLAB crash; given that MathWorks does not have the source code for this MEX function, the author is the best resource for troubleshooting issues with it.
For more information regarding MEX functions, refer to the following documentation page:
 

  0 Comments

Sign in to comment.


Answer by L A
on 6 Sep 2018

Thanks for this contribution. I located the RunMexFile line in the crash dump (line [4]). So line [3] should be the issue? How can this be interprted?
[ 3] 0x000007feece41334 C:\VeriStand\2017\UserInterface\tmw\Shared\NIVeriStand_mex_util.mexw64+00004916 mexFunction+00000644 [ 4] 0x00000000fc5fc5d1 C:\Program Files\MATLAB\R2016b\bin\win64\libmex.dll+00116177 mexRunMexFile+00000129
Best wishes Lysandros

  0 Comments

Sign in to comment.