matlab crashed when calling MEX
19 views (last 30 days)
Show older comments
I successfully converted my MATLAB source code to CUDA C code using GPU coder and generated a MEX file, but when I call the MEX file, matlab crashes and quits. The matlab_crash_dump in the TMEP folder shows the following. Can anyone tell me what went wrong or how to find this error?
--------------------------------------------------------------------------------
Access violation detected at 2025-04-05 16:19:22 +0800
--------------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled - No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
Graphics Driver : Uninitialized hardware
Graphics card 1 : NVIDIA ( 0x10de ) NVIDIA Tesla V100-SXM2-32GB Version 31.0.15.3625 (2023-6-10)
Graphics card 2 : NVIDIA ( 0x10de ) NVIDIA Tesla V100-SXM2-32GB Version 31.0.15.3625 (2023-6-10)
Graphics card 3 : NVIDIA ( 0x10de ) NVIDIA Tesla V100-SXM2-32GB Version 31.0.15.3625 (2023-6-10)
Graphics card 4 : NVIDIA ( 0x10de ) NVIDIA Tesla V100-SXM2-32GB Version 31.0.15.3625 (2023-6-10)
Graphics card 5 : NVIDIA ( 0x10de ) NVIDIA Tesla V100-SXM2-32GB Version 31.0.15.3625 (2023-6-10)
Graphics card 6 : NVIDIA ( 0x10de ) NVIDIA Tesla V100-SXM2-32GB Version 31.0.15.3625 (2023-6-10)
Graphics card 7 : NVIDIA ( 0x10de ) NVIDIA Tesla V100-SXM2-32GB Version 31.0.15.3625 (2023-6-10)
Graphics card 8 : (标准显示卡类型) ( 0x19e5 ) Microsoft 基本显示适配器 Version 10.0.22621.1 (2006-6-21)
Graphics card 9 : NVIDIA ( 0x10de ) NVIDIA Tesla V100-SXM2-32GB Version 31.0.15.3625 (2023-6-10)
Interpreter 0 : Executing request: 4D61746C6162526571756573742E637070
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 9811929
MATLAB Root : D:\Program Files\Matlab
MATLAB Version : 24.2.0.2863752 (R2024b) Update 5
OpenGL : hardware
Operating System : Microsoft Windows 11 专业版
Process ID : 15416
Processor ID : x86 Family 6 Model 85 Stepping 4, GenuineIntel
Session Key : 140956f8-750d-47f4-81ea-83acb9360395
Window System : Version 10.0 (Build 22631)
6 Comments
Manikanta Aditya
on 7 Apr 2025
@Shi, I can tell you to check the temporary files directory. On Windows, crash logs are typically stored in the temporary files directory. You can access this directory by entering %temp% in the Windows search bar or by navigating to C:\Users\<YourUsername>\AppData\Local\Temp
Refer this MATLAB Answer post: How do I locate the crash dump files generated by MATLAB? - MATLAB Answers - MATLAB Central.
You can also use the following MATLAB command to open the temp directory:
cd(tempdir)
- MATLAB generates crash dump files with names like matlab_crash_dump.XXXX, java.log.XXXX, and hs_error_pidXXXX.log1. These files contain valuable information for debugging.
Justin Hontz
on 7 Apr 2025
@Shi Unfortunately, the crash log does not provide much information about what exactly went wrong. With that said, the following are some initial debugging steps that you can try:
- See if you can reproduce the crash using MATLAB Coder without using GPU Coder.
- Try simplifying / minimizing the entry point you are generating code for until the issue is no longer reproducible to help narrow down the source of the issue.
Accepted Answer
Manikanta Aditya
on 7 Apr 2025
Try out some troubleshooting steps to see if you can fix the issue:
- Ensure that the input arguments passed to the MEX file are correctly formatted and of the expected type. Mismatched data types can cause crashes.
- Ensure that memory allocation and deallocation are handled correctly in your CUDA C code. Improper memory management can lead to access violations.
- Verify that your GPU drivers are up to date and properly configured. The crash log indicates multiple NVIDIA Tesla V100 GPUs, so ensure they are correctly initialized and accessible.
MATLAB Code to call MEX file (Debug):
try
result = myMexFunction(inputData);
catch ME
disp('Error occurred while calling MEX file:');
disp(ME.message);
end
- I found an relevant MATLAB Answer post that might help you: How do I troubleshoot a MATLAB crash associated with a MEX function? - MATLAB Answers - MATLAB Central (Try out the told workarounds, they might help.)
- Refer this resource as well to understand more: error handling - MATLAB crashes when executing a mex file - Stack Overflow
I hope this helps you.
2 Comments
Chao Luo
on 8 Apr 2025
Hi Shi,
We cannot figure out the issue with this report. Can you reach out to customer support to provide the reprodcution with your MATLAB design? Once we have your files, we can investigate more.
More Answers (0)
See Also
Categories
Find more on Get Started with GPU Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!