My QT crashed tons of times yesterday.

With no report message, it took me a lot of time to find out what happened. Eventually, the cause was silly, but it pushed me to know more about C++.

What happened

Yesterday, I was keeping working on my QT client, which is responsible to update and query data from sever with authentication. The authentication parts went great and I was about to finish the HTTP parts.
The development is driven by unit tests so I was pretty sure that every function I wrote works fine. However, when I implemented my last public interface which looks like this:

QJsonObject DashBoard::getRecordByJobId(QString jobId) {
    qnam = QSharedPointer<QNetworkAccessManager>(new QNetworkAccessManager);
    connect(, SIGNAL(finished(QNetworkReply*)), this, SLOT(onGetRecordByJobIdReply(QNetworkReply*)));

    QByteArray postData;

    makePostRequest("/query", postData);

And test.cpp:

void UnitTester::testQuery() {

Bad things just happened. I just couldn’t run test on it. Every time it just crashed with no message. There was also no warning or error thrown by QT. This snippet of code was pretty much a copy of former code I wrote with a couple of trivial changes.

What I did

All function called inside this newer one was tested before so I was pretty sure they work. I got no clue but ran debug mode and commented/uncommented code.
It was strange that every time debugger just stopped working at some point. I set several break points by still couldn’t find why. So was my latter attempt.
By searching Stack Overflow and other references, I found out that instead of crashing, debugger would stopping at where it crashed and refused to step over and step into anymore. That’s a big hint.

How I solved.

I canceled all break points and ran debugger again. It stopped at makePostRequest("/query", postData);. It was exactly what I want. But this function involved nested call stack and I had waste a lot of time debugging inside that mess.
Eventually, I notice that QT throw a warning after where debugger stopped. It helped a lot because it told me the issue was caused by next line rather than makePostRequest. With the hint, I found out I forgot to RETURN A VALUE. (The functions I copied from was void)
I had to admit that I was spoiled by Java and IntelliJ, who would tell me every time I left out the return statement. However, QT won’t check everything when compiling like your parent. But obviously you have to take whatever you did in runtime…
Naive. Still a way to go!