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

QProcess waitForFinished crashed



  • My program crashed. After I dump the exe and Qt5Core.qt_crash.png dll I found it was crashed at QProcess.waitForFinished.
    Here is my code, I use Qprocess to execute a command and wait it finished.
    It doesn't crash every time, the crash possibility may lower than 0.1%.

    ```
    

    QProcess cmd = new QProcess(this);
    cmd->start("some command");
    cmd->waitForStarted();
    cmd->waitForFinished(-1);



  • @terryGGG

    It doesn't crash every time, the crash possibility may lower than 0.1%.

    I don't think anyone will be able to solve this for you from what you show. And you do not say what version of Qt you are using, which might be relevant.

    Write yourself a standalone program, as minimal as possible [~20 lines?], which just does your code, 10,000 times in a loop. Make the command something simple & harmless, say dir or echo hello. Does it crash? Does it matter what the command is?

    If you do get a crash: get rid of both

    cmd->waitForStarted();
    cmd->waitForFinished(-1);
    

    and replace with the QProcess signal/slots equivalent, so no waitFor...() calls, which can be "dodgy", especially potentially under Windows. Does that crash?


Log in to reply