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

QProcess::waitForStarted crashes if start() failed early

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Duplicate
    • Affects Version/s: 4.8.1, 5.1.0
    • Fix Version/s: 5.2.0
    • Component/s: Core: I/O
    • Labels:
      None
    • Environment:
      Linux

      Description

      The "unix" implementation of QProcess::waitForStarted() crashes if start() failed. This can be triggered by, for example, passing a non-existent path to setStandardInputFile(). While this can be avoided by checking error() after calling start() (and before calling waitForStarted()), it probably shouldn't crash either.

      I've done some source-code digging and pinpointed the problem:

      • QProcessPrivate::startProcess() returns without setting up childStartedPipe if some setup failed.
      • QProcessPrivate::waitForStarted() does an FD_SET() with the read end of the pipe, which is -1 because the pipe was not set up.
      • FD_SET() crashes with a negative file descriptor.

      I guess this could be fixed by simply checking childStartedPipe in QProcessPrivate::waitForStarted() and returning false if it's not set up. That would also catch accidentally calling waitForStarted() without calling start() at all.

      Note: I encountered the problem with Qt 4.8.1 (as currently shipped with ubuntu 12.04). I also checked the latest Qt5 sources from git and the problem seems to be the same there, but I have not tested that.

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              thiago Thiago Macieira
              Reporter:
              mschmitzer Marc Schmitzer
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes