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

[REG-5.0->5.1] [Windows] PowerShell script started via QProcess freezes in certain conditions

    XMLWordPrintable

Details

    Description

      When starting a PowerShell script via QProcess and not manually redirecting the stdin via setStandardInputFile(), a [Console]::ReadLine call within the PowerShell script freezes the computation of the script independently of write calls in QProcess.

      Steps to reproduce the issue:
      1. Run the attached test application
      2. Close MessageBox of the PowerShell script ("Loop begin")

      Outcome: The PowerShell script freezes in ReadLine. Subsequent write calls from the Qt code have no influence now. The PowerShell script does not continue and finish.

      Tested on:
      Windows7 with PowerShell >=4.0

      Notes:
      The Qt implementation is in qtbase\src\corelib\io\qprocess_win.cpp function static void qt_create_pipe(.)

      A named pipe is created with flag FILE_FLAG_OVERLAPPED.
      Later in this function, ConnectNamedPipe() is called with NULL as Overlapped argument (152) :

      // Wait until connection is in place. 
      ConnectNamedPipe(hServer, NULL); 
      

      This is not allowed according to the Microsoft documentation - and seems to cause the problem:
      https://msdn.microsoft.com/en-us/library/windows/desktop/aa365146(v=vs.85).aspx

      "If hNamedPipe was opened with FILE_FLAG_OVERLAPPED, the lpOverlapped
      parameter must not be NULL. It must point to a valid OVERLAPPED structure."

      The FILE_FLAG_OVERLAPPED flag was introduced in "QProcess/Win: use named pipes for redirecting standard I/O" 9efbc9f60a511e902d3f8b368296212b43222f52 https://codereview.qt-project.org/#/c/12475/ .

      Attachments

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              kileppal Kimmo Leppälä
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes