my Qt (QML/C++) application crashes and I can not find the reason why. I tried to output a lot of information but some signal/slot connection probably causes a crash. I spent many hours trying to find the reason but I failed.
The only good point is that I can reproduce the crash whenever I want.
Unfortunately I don't know hot to use the included GDB debugger. This is the output I got:
How do I find from this what happened and where? I need to find at least the function, in which my application crashed.
Or what else could I try? Unfortunately I can not disable the signal/slot connections or the associated functions, because then I can not get to the point, where it crashes.
Qt has detailed documentation on how to install a debugger found here: QtCreator Debugger
MingW does have a GDB that can be used to debug the application better. You can also use CDB to debug, just depends on your preference.
Once that is installed, you'll be able to set breakpoints and check variable information to see where your program is crashing using the Debugger view in QtCreator.
Tools->Options->Build & Run
If you have Qt version kit like this you need to check debuggers.
https://i.stack.imgur.com/LaY1p.png
https://i.stack.imgur.com/8kTG6.png
You need to install MinGW and after install you will be have debugger. After install press F5 to start debuging.
Related
Having one heck of a time debugging a crash in a Windows Service that I've build with QT and Boost Logger on Windows using MSYS2 environment. The main issue really comes when I stop the program right before exit. The program just doesn't exist successfully and throws one of these bad boys:
If I was running it in gdb it might be a different story. I open the crash dump in windbg and get some info, but since the symbols aren't exported it's really cryptic.
I see some issues when my program (called service) is calling the log. But I can't do much here in the way of where or what. How can I get something useful so I could finally solve this issue?
Thanks so much!
Seems like the easiest and most natural way was to attach gdb to the running process. I simply ran msys2 as Administrator, then ran the command
gdb service.exe -p [processID]
Task manager gave me the process ID. As soon as the process was attached I just used the command
continue
to get it to continue running. Then I let it crash and gdb gave me the backtrace perfectly.
I've searched a bit for this and this was much simpler than trying to get windbg to read the symbols generated by g++ or read the assembly code. Hope this helps somebody having the same issue.
References:
How to attach a process in gdb
I've looked for an answer during a few days and I haven't found anything similar anywhere;
I downloaded Qt from the official website, installed it and apparently compiling is fine. But whenever I try to execute (Ctrl+R) any app, even the basic one which only displays a window or widget, QtCreator itself crashes. No error message, nothing, just crashing.
I've tried to redownload and reinstall it a few times with different settings, but nothing will do.
I'm running QtCreator on Windows 7 64 bits. I'll try on my laptop which is also running windows and will update if I find anything.
Any help would be appreciated, I need to start a project as soon as possible. I'm relatively new to QT and if you need info on anything just ask me. Thanks :)
Use dependency walker, http://www.dependencywalker.com/
and post any missing dependencies. It is possible some install targets or options are missing from when you installed QtCreator, which can be resolved with the maintenance tool in the same directory you installed Qt.
Also, are you using the Visual Studio compiler(must have Visual Studio installed separately, and mark the option during install), or the Ming compiler(2 options checked during install or maintenance)?
Check if your antivirus is locking it, I had a similar issue time ago and it was due to antivirus (Avast specifically). Disable antivirus' realtime shields and try to execute a basic app.
It is necessary to use QtCreator? I use QtDesigner snd VS2013 and things go very well. :)
check this thread Qt Creator Plain C++ Project won't run/debug... and this C++ - QtCreator doesn't show any output
I set Qt Creator to break when a C++ exception is thrown:
I then tested it with this code:
try {
throw std::runtime_error("error");
} catch (std::exception &e) {
qDebug("%s", e.what());
}
But it didn't break on throw std::runtime_error("error");. I'm using CDB, not GDB, because I'm using the MSVC Kit.
Edit: There is another question where CDB is working for the OP, even if slowly. So it should work in principle. My configuration is: Qt Creator 3.3.0, compiling with Qt4/MSVC 9.0 (x86), the debugger is CDB 6.2.9200.16384.
Edit 2: This is what I'm getting in the CDB log window (I made a diff between the CDB log with and without the breakpoint):
<bu100400 CxxThrowException
<!qtcreatorcdbext.breakpoints -t 1 -v
<!qtcreatorcdbext.pid -t 2
dATTEMPT SYNC
d*** Bp expression 'CxxThrowException' contains symbols not qualified with module name.
1 breakpoint(s) pending...
*** Unable to resolve unqualified symbol in Bp expression 'CxxThrowException' from module 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18201_none_ec80f00e8593ece5\comctl32.dll'.
Full CDB log (in case needed): http://pastebin.com/jhNRy9bE
Edit 3: #HansPassant's explained why it fails in the comments:
Keep in mind that you are using a very old version of MSVC++, big changes at VS2012. The pastebin shows it being out of sync pretty badly, never getting to the DLL that contains __CxxThrowException#8 (MSVCR90D.dll) before the exception is thrown. It is simple with the sxe debugger command, automatic break when any exception is thrown.. Maybe you shouldn't be using QT's UI at all, it looks too gimpy. – Hans Passant 10 hours ago
Just look at the trace, the debugger shows what DLLs it is searching for "CxxThrowException". It never gets to msvcr90d.dll. And the exception is thrown while it is searching for the symbol after which it all ends. Completely out of sync. – Hans Passant 56 mins ago
I'll just write up why this is going wrong, a workaround is going to be difficult to find. The debugger trace in your pastebin tells the tale.
The basic issue is that the communication between the debugger and the QT front-end is rather poor. And in your case it gets out of sync, QT doesn't wait long enough for the debugger to complete the command. QT tries to set a breakpoint on the msvcr90d.dll!__CxxThrowException#8 function, the one that raises a C++ exception in the Microsoft CRT. This function can be present in more than one executable file if the program uses multiple CRTs. A pretty common mishap, caused by building with /MT. And sometimes intentional if you use a well-isolated DLL that you interface with by using COM.
This takes a while as you might imagine, the complaint in the linked question, the debugger has to plow through the symbol information for every DLL that's loaded. It will take especially long if the PDB for the DLL needs to be downloaded from the symbol server and doesn't otherwise get cached so it is available the next time you debug. Not your issue afaict, it does setup the cache location to C:\Users\sasho\AppData\Local\Temp\symbolcache. Go have a look-see to verify that you do see PDBs for the operating system DLLs there.
This operation is tricky, the debugger doesn't give a good signal that it is done searching the DLLs. What the QT should do is verify the debugger feedback against the list of DLLs it obtained. It does not do that, it issues the g command before the debugger is done searching. Could be a timeout that is too short but it actually looks like QT doesn't count on the debugger performing this command in the background. A convenience to a human, not exactly very helpful here :)
There ought to be a way to configure CDB to not perform this search in the background. This is well-hidden, I don't see anything in the debugger.chm help file but it probably wasn't updated in a while. Google doesn't help either. I'd recommend you ask a question about it. Most significantly perhaps is that you have a rather major mismatch in version numbers. The compiler you use is 2008 vintage, the debugger is quite new, SDK 8.0 version, I can't tell what QT version you use.
So a possible workaround is to intentionally use an older version of CDB, one that's more likely to have been tested with the QT front-end version you use. Download the corresponding SDK version, version 6.0 matches the VS2008 time frame. I think the "Debugging Tools for Windows" was still a separate download back then and not yet included in the SDK. Another workaround is to stop relying on the friendly QT front-end and learn to drive CDB from the command prompt. Moderately more useful is WINDBG, uses the same debugging engine but has a GUI interface. Just moderate, it is still mostly prompt driven. You do lose several days of your life learning the commands however. Getting the debugger to break when an exception is thrown is trivial, use the sxe command.
I finished migrating an application from Qt4 to Qt5, it compiles and runs but as soon as the main window is opened I cant do anything (interact with items, or click or anything). its just not responding. I tried debugging it but in the main.cpp reaches the return a.exec(); statement and trying to debug further than that is not posible, the yellow arrow wont go anywhere past that, and if I insist too much it eventually disappears. The functionality of the program is supposed to be alright, I only migrated it.
What can be causing of this problem? I would post some code but there are so many .cpps and I have so little clue about the issue that I dont know what to post.
I know its not much information, but if anyone has had this problem or knows something related to these symptoms please just say it, it will be better than nothing.
If I missed anything please tell me
Thankyou.
Some more info
Platform: Windows 7 x64
Compiler: MinGW 4.8 32bits
Application: 32bits
I did compile all the libraries and the app in debug mode (except some such as Qxt, which is compiled with the command line and zlib and Qt5SerialPort which includes the debug version itself)
Try disabling all child widgets in your main window and then turn them on one at a time till you find which one is causing the blocking.
Issue
I am having difficulty debugging inside of my application's timerEvent functions. While the application is able to run, if I set a breakpoint inside of even something as simple as the following, I receive an error message stating: "The gdb process crashed."
void MyClass::timerEvent (QTimerEvent *e) {
std::cout << "TIMER!";
}
I have included a debugger log here via pastebin.
Attempts
To try and fix this, I tried upgrading gdb iteratively with each version of QT-creator to no avail.
I am using:
Linux ubuntu-x86 2.6.32-42-generic #95-Ubuntu 10.04LTS SMP i686 GNU/Linux
QT creator (versions 2.4 through 2.5.2)
gdb (7.1 through 7.5) targeting "x86-linux-generic-elf-32bit"
pythongdb (7.2)
Questions
My questions are twofold, namely:
What is causing gdb to crash?
and
What can I do to make it work?
Failing that, I wonder: Where else should I look for more details of the crash?
Any and all help is greatly appreciated.
Make sure your QT libraries are up to date. Even though a new QT-creator will install via the handy-dandy .bin file they provide, it was built using the newer QT libraries, and expects them to be in place. If they are not, well...
Additionally, if you are not installing gdb into one of the standard directories where QT-creator can find it, make sure you add it manually to your toolchains via tools->options->build and run->toolchains.