Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtCreator debugger not behaving deterministically



  • I'm trying to debug a Qt application, but I'm having several issues. Firstly, when I hit a breakpoint (or when the program gets to a stationary state (open window waiting for user input)) the application output just stops. Mid string, with 30 more strings in the buffer. I've tried flushing the buffer before the breakpoint, but to no avail.

    Secondly, I have bugs that disappear when I place breakpoints at a certain part of the code (mainly somewhere prior to the bug).

    I've tried this on three different machines, Macbook Air (early 2015, Mojave), iMac (27", late 2013, Catalina) and a hackintosh VM (Catalina).
    Other colleagues are working on the same project, nobody else has the problem.

    My WTR on iMac has literally been, install the OS, download QtCreator, install QtCreator, clone the project repository, run the debug build.

    I never changed the default kits or any settings in the QtCreator.

    My current working theory is that Apple has my picture, hates me and makes macs act stupid if they detect me in front of them. I have no other theories that would make more sense at this point, so I'm open for any suggestions.



  • @Karlovsky120 said in QtCreator debugger not behaving deterministically:

    Other colleagues are working on the same project, nobody else has the problem.

    That's worrying :( Especially if you say you try it on different machines and it only goes wrong for you.

    My current working theory is that Apple has my picture, hates me and makes macs act stupid if they detect me in front of them

    If what you describe is true, this seems like the most likely explanation ;-)

    One thing you should certainly do is make sure the "debug" folder is absolutely empty before you do a full rebuild. Any artefacts lying around could result in odd behaviour.

    I don't know how it works on Mac, but make sure your compiler/debugger themselves are correctly installed, can they be uninstalled/reinstalled?

    Secondly, I have bugs that disappear when I place breakpoints at a certain part of the code (mainly somewhere prior to the bug).

    Unfortunately, this is actually not totally impossible/incorrect. For example, this has happened to me in Qt code to do with signals/slots because of timing code buried in Qt which causes different behaviour in debugger against not in debugger, or how you actually step through in debugger. Also "uninitialized/incorrect" memory data can show up in different ways as you debug/run your code, and in that sense you should regard it as causing potentially "non-deterministic" behaviour.

    I hope I'm not speaking out of turn, but from what you describe (especially with it working for other people, but not working for you across multiple machines) I don't see how anyone reading this will be able to pinpoint your problem, I'm afraid? However, you might state the exact versions of Qt/Qt Creator/compiler/debugger you are using in case those are relevant.

    Oh, and does the "bad debugger" happen to you on a minimal project (e.g. a "Hello World"), or only on your actual fair-sized project code?



  • Yeah, I was a bit stingy with the information. However, I've since discovered that the debugger behavior is consistent, at least when it comes to breakpoints and general code behavior, the only issue is that stopping at a breakpoint stops the program output. For example, the following program gives this output when it hits the breakpoint:

    #include <QDebug>
    #include <unistd.h>
    
    int main(int argc, char *argv[])
    {
        for (int i = 0; i < 20; ++i) {
            qDebug() << "Printing line " << i << "\n";
        }
        int a = 0; // <-breakpoint here
    }
    
    07:50:37: Debugging starts
    2020-09-04 07:50:44.162658-0700 editor[3615:65377] Printing line  0
    2020-09-04 07:50:44.162689-0700 editor[3615:65377] Printing line  1
    2020-09-04 07:50:44.162695-0700 editor[3615:65377] Printing line  2
    2020-09-04 07:50:44.162699-0700 editor[3615:65377] Printing line  3
    2020-09-04 07:50:44.162702-0700 editor[3615:65377] Printing line  4
    2020-09-04 07:50:44.162706-0700 editor[3615:65377] Printing line  5
    2020-09-04 07:50:44.162709-0700 editor[3615:65377] Printing line  6
    2020-09-04 07:50:44.162713-0700 editor[3615:65377] Printing line  7
    2020-09-04 07:50:44.162716-0700 editor[3615:65377] Printing line  8
    2020-09-04 07:50:44.162720-0700 editor[3615:65377] Printing line  9
    2020-09-04 07:50:44.162724-0700 editor[3615:65377] Printing line  10
    2020-09-04 07:50:44.162727-0700 editor[3615:65377] Printing line  11
    2020-09-04 07:50:44.162731-0700 editor[3615:65377] Printing line  12
    2020-09-04 07:50:44.162735-0700 editor[3615:65377] Printing line  13
    2020-09-04 07:50:44.162751-0700 editor[3615:65377] Pri
    

    It just stops mid string like this. I've tried redirecting output to the terminal, but that just exits right away, without outputting anything. If I add usleep(20000); above the print line, it will print out all (20) of the strings. If I add usleep(10000); it will get to number 16.

    I'm using QtCreator 4.13.0, Qt 5.15.0.
    I'm using Clang that came with MacOS Catalina (x86 64bit in /usr/bin).
    I'm using LLDB that came with it (also in /usr/bin/lldb).

    This is a fresh install of the OS, there is nothing else installed on the system except the programs that came with it. MacOS version is 10.15.5.


Log in to reply