Details
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.