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

[macOS] QProcess works buggy under debugger

XMLWordPrintable

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

      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.

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:

                There are no open Gerrit changes