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

QProcess::waitForFinished() hangs on macOS 10.15 when elevated through osascript

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9.8, 5.13.1
    • Core: I/O
    • None
    • macOS 10.15 with XCode 11.1
    • macOS

    Description

      We are using the osascript (AppleScript) elevation technique to elevate our app's update process. This process is internally using QProcess to execute some system commands. After updating to macOS 10.15 Catalina and XCode 11.1 we have noticed that execution of QProcess.waitForFinished() always times out even though process correctly prints its output to stdout. For some reason child process is left in a zombie state and is never reaped by the caller.

      This case happens when executing any command via QProcess from executable as long as the executable which launches QProcess is launched through osascript with admin elevation like this:

      osascript -e 'do shell script "<path_to_compiled_executable>" with administrator privileges';

      If the same case is executed without admin elevation, i.e.

      osascript -e 'do shell script "<path_to_compiled_executable>"';

      program works correctly and waitForFinished() call does not time out. If executable is launched with sudo to run it as admin - such issue is not present as well.

      According to Apple (scroll down to last response by eskimo), they have changed something about how command is elevated in osascript. This might be what is causing this anomaly with QProcess.

      Here is the minimal code example to reproduce this issue:

      #include <QProcess>
      int main(int argc, char** argv)
      {
         QProcess process;
         process.start("whoami"); // It does not matter which command is executed here
         process.waitForFinished(-1);
         return 0;
      }
      

      I am also attaching two shortened dtruss logs taken from a slightly modified code sample as they might be useful.

      We have noticed this issue with Qt 5.9.8, but it also present in 5.13.1. Same piece of code compiled with an older XCode version (10.x) still hangs when executed on macOS 10.15 as well.

      Please let me know if you need anything else to diagnose or reproduce this issue.

      Attachments

        1. backtrace.txt
          1 kB
        2. dtruss_bad.txt
          2 kB
        3. dtruss_good.txt
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            sergejus.topolovas Sergejus Topolovas
            Votes:
            3 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes