How do I troubleshoot a MATLAB crash associated with a custom MEX function?
84 views (last 30 days)
MathWorks Support Team on 24 Jun 2021
Edited: MathWorks Support Team on 24 Jun 2021
In order to troubleshoot your crash, first you need to determine which MEX function caused MATLAB to crash. Depending on whether you are the author of this MEX function, you have multiple options to troubleshoot the MEX function.
=Determine which MEX function caused MATLAB to crash=
First, you need to obtain the latest crash log from MATLAB. Refer to the MATLAB Answers post below for information on locating the crash dump file (matlab_crash_dump.XXXX) MATLAB generates:
Once you have the crash log associated with your recent crash, refer to the following MATLAB Answers post to identify the MEX function that caused MATLAB to crash:
=Out-Of-Process Execution of C++ MEX API Based Functions=
If you are using C++ MEX API, you can run your MEX function in a process that is separate from the MATLAB process. Executing the MEX function in a separate process can prevent MATLAB from crashing if the MEX function crashes and can make it easier to troubleshoot MEX functions. Please refer to the following to learn more about Out-of-Process execution of C++ MEX functions:
Please note that this feature is available only for C++ MEX API based functions and cannot be used with C MEX API based functions.
Please visit the following link to see how to create C++ MEX API based functions:
=Troubleshoot the MEX function=
Once you know which MEX function caused MATLAB to crash, there are two options depending on the authorship of the MEX function.
You are the author of the MEX function:
The documentation has resources for troubleshooting MEX functions. Please refer to the following documentation pages for more information on debugging MEX functions:
-Introducing MEX functions-
-Troubleshooting MEX functions-
If you are unable to utilize the information in the documentation to troubleshoot your custom MEX function, you can contact Technical Support for help on using the available resources for you to troubleshoot your MEX function. Note that Technical Support can provide guidance on MEX setup issues, compilers, library dependencies and give general best practices for MEX function creation and debugging only.