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

QProcess::waitForStarted crashes if start() failed early

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P1: Critical
    • 5.2.0
    • 4.8.1, 5.1.0
    • Core: I/O
    • None
    • 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

          For Gerrit Dashboard: QTBUG-33021
          # Subject Branch Project Status CR V

          Activity

            People

              thiago Thiago Macieira
              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