Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-97990

[macOS] QProcess works buggy under debugger

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • Some future release
    • 5.12.11, 6.2.1
    • QML: Tooling
    • None
    • macOS 11.5.1
    • macOS

    Description

      I'm trying to run bash script:

      auto marker = QUuid::createUuid().toString(QUuid::WithoutBraces);
      marker.replace("-", "");
      
      auto cmd = QString("echo -n %1${PATH}%1").arg(marker);
      
      auto args = QStringList()
              << "-l"
              << "-c"
              << cmd;
      
      QProcess *p = new QProcess;
      connect(...);
      p->start("/bin/bash", args);
      

      The bug is that under the debugger finished signal is never emitted. I've tried to add 15 seconds  timeout (using QTimer) with the following code:

      onTimeout() {
           process->kill();
           auto output = process->readAll();
           process->waitForFinished();
      }
      

      QProcess::kill() does nothing actually. It still does not generate any events, QProces is still "running".
      Output contains all the required output. I.e. all the expected output from the process is received already.
      QProcess::waitForFinished does not return immediately and waits its 30 seconds interval.

      I've tried to make a simple reproduce example and failed to do it. It does not reproduce inside of a simple app. It looks like some sort of race condition bug inside of QProcess, which requires some specific conditions to reproduce.

      And, as I've stated already, the problem happens under running debugger only. I can't reproduce it if I just run my application.

      Addition #1. Some more info discovered. If, some time later, I launch one yet process using QProcess (some console application), then, after I receive output from it, I also finally receive finished signal from my staled buggy QProcess. This is true for Qt5. Qt6 works worse. Please see comments.

       

      Attachments

        1. untitled.zip
          9 kB
          Alexander Dyagilev
        2. image-2021-12-15-11-03-27-341.png
          8 kB
          Alexander Dyagilev
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtqmlteam Qt Qml Team User
            alervd Alexander Dyagilev
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes