Maltab throws segmentation fault when debugging mex function

10 次查看(过去 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)

回答(2 个)

Image Analyst
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
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.
Steve Oswald
Steve Oswald 2021-12-20
编辑:Steve Oswald 2022-1-4
I stated that it was not matlab crashing,
but thanks for the input :)

请先登录,再进行评论。


Gunter Nitzsche
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.

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by