Maltab throws segmentation fault when debugging mex function
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello,
I'm trying to debug a s-function in a simlulink model. However, when i attach to the matlab process, before running any models, I get a segmentation fault event.
I'm attaching the the matlab.exe process using visual studio code with the gdb from the matlab installation. Here is my launch.json snippet:
{
"name": "(gdb) attach",
"type": "cppdbg",
"request": "attach",
"program": "C:\\Program Files\\MATLAB\\R2019b\\bin\\matlab.exe",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"miDebuggerPath": "C:\\ProgramData\\MATLAB\\SupportPackages\\R2019b\\3P.instrset\\mingw_w64.instrset\\bin\\gdb.exe",
"symbolLoadInfo": {
"loadAll": true,
"exceptionList": ""
},
"setupCommands": [
{
"description": "Automatische Strukturierung und Einrückung für \"gdb\" aktivieren",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
This is the debugger output:
Thread 53 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 7672.0x2de8]
0x000001f4 in ?? ()
How can matlab throw SIGSEGV segmentation fault without crasing?
As I said, I did not execute any scripts yet in matlab, only started matlab and attached to the process.
The SIGSEGV comes multiple times, even after I continue
Is this a faulty matlab installataion/configuration/debugging configuration?
I've noticed that the adress is displayed in 32 bit, even though I'm running 64 bit
This is the thread information I can see:
[Unknown/Just-In-Time compiled code] (Unknown Source:0)
jvm.dll!jvm!??_7SpeculativeTrapData@@6B@ (Unknown Source:0)
[Unknown/Just-In-Time compiled code] (Unknown Source:0)
댓글 수: 0
답변 (2개)
Image Analyst
2021년 12월 20일
Did you send in the error report? Did it even ask you about the error report when you restarted MATLAB?
Otherwise, see the FAQ:
and do what it says.
댓글 수: 3
Image Analyst
2021년 12월 20일
Well I don't know. If it's a problem with your code, or your mex source code or DLL, or Visual Studio, not with MATLAB itself, you probably won't get any or much help from Mathworks, and you'd be on your own.
Gunter Nitzsche
2023년 3월 16일
Even though, the question is quite old I post the answer, because while looking around how to do debugging with VS Code I came across a possible solution:
There it is mentioned, that Matlab internally throws SIGSEGVs but catches and handles them. When you run the debugger, it stops there. That is also the reason, why you do not see Matlab crash. It handles the SIGSEGV and carrys on.
However, I currently have the issue, that gdb cannot intercept Matlab and install the breakpoints. So I am quite happy about the SIGSEGV to cause a first interrupt, which then enables by breakpoints. This is only necessary when debugging via VS Code. When running gdb in a terminal I do not need this workaround.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!