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

QProcess segfaults if it runs out of file descriptors

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 4.8.5, 5.1.0
    • 4.6.3, 4.7.2, 4.7.3
    • Core: I/O
    • None
    • Linux (Debian stable)
    • 8efad82d6c8b0f59c5acb7f355ad2742f17b91df f391ec72c2e4416bf8e5d7482ace49247cc2017c

    Description

      If you start lots and lots of QProcesses, you get a segfault. See backtrace below from Qt 4.6.3:

      QProcessPrivate::createPipe: Cannot create pipe 0xe919bf8: Too many open files
      QSocketNotifier: Invalid socket specified
      
      Program received signal SIGSEGV, Segmentation fault.
      [Switching to Thread 0x6106bb70 (LWP 9707)]
      0xb727e2c1 in QEventDispatcherUNIX::registerSocketNotifier (this=0xe8ec5e0, notifier=0xe919ee0)
          at kernel/qeventdispatcher_unix.cpp:765
      765	kernel/qeventdispatcher_unix.cpp: No such file or directory.
      	in kernel/qeventdispatcher_unix.cpp
      Current language:  auto
      The current source language is "auto; currently c++".
      (gdb) bt
      #0  0xb727e2c1 in QEventDispatcherUNIX::registerSocketNotifier (this=0xe8ec5e0, notifier=0xe919ee0)
          at kernel/qeventdispatcher_unix.cpp:765
      #1  0xb726c3b4 in QSocketNotifier (this=0xe919ee0, socket=-1, type=QSocketNotifier::Read, parent=0xe8eb538)
          at kernel/qsocketnotifier.cpp:184
      #2  0xb722d286 in QProcessPrivate::startProcess (this=0xe919aa0) at io/qprocess_unix.cpp:543
      #3  0xb71e6649 in QProcess::start (this=0xe8eb538, program=..., arguments=..., mode=...) at io/qprocess.cpp:1917
      

      If you run out of file descriptors, QprocessPrivate::startProcess fails to create the childStartedPipe and or deathPipe, getting socket values of -1. If you pass an invalid socket (-1) to QSocketNotifier's constructor, it warns, but then goes on to call

      d->threadData->eventDispatcher->registerSocketNotifier(this);

      which segfaults when this->sockfd is -1.

      QProcessPrivate::startProcess should handle the childStartedPipe and deathPipe failing to be created, and QSocketNotifier shouldn't try to register the notifier if the provided socket is not valid.

      Attachments

        1. executor.hh
          0.5 kB
        2. main.cc
          0.2 kB
        3. patch.patch
          3 kB
        4. qprocess_unix.patch
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bladud Simeon Bird
            mark_mackey Mark Mackey
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes