Home > OS >  Debugger does not show my code after a segmentation fault
Debugger does not show my code after a segmentation fault

Time:02-23

I'm using Qt 6.2.0, Qt Crator 5.0.2, Ubuntu 20.04. I built my Qt application in Debug mode.

I surely made some errors in my code because it fires a segmentation fault. My problem is I'm not able to find the offending line because the debugger does not show anything useful (at least to me!).

enter image description here

As you can see in the call stack there are only greyed lines - that means "assembler" code. I tried to inspect all the threads but no one shows my code.

Does this mean I have a wrong setup of the debugger? If it's fine (it may happen such a scenario) how to find out the exact point that fires the segmentation fault?

I tried to place here and there some qDebug() instructions, but it's not so trivial...

CodePudding user response:

try to start the debugger with a breakpoint on the first line of your code in the main.cpp file where QApplication instance is creating. if it doesn't catch therethen the problem is in your debug configuration but if it breaks on the breakpoint then try to step over and step in to see where the problem will raise.

CodePudding user response:

Segmentation faults happen when somewhere memory not owned by our process (at least not yet owned), is accessed (read or written).

In other words, you pass an invalid pointer somewhere to Qt, or you delete an object that is still in use by Qt.

So the crash happens in Qt framework's code, although caused by your code; your screenshot seems to show a QML-Property related stacktrace, and you should use it to pinpoint the actual reason (for example, search in stacktrace's variables, and find QML property's name).

  • Related