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

QAbstractSocket::waitForReadyRead() crashes if the server has opened many files

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 4.7.4, 4.8.0
    • Network: Sockets
    • None
    • Linux 64 bit

    Description

      When there is an incoming connection and QAbstractSocket::waitForReadyRead function is called it receives a segmentation fault signal and crashes.

      This happens only on 64bit Linux.

      Sometimes (it depends on the PC) the application(server-side) doesn't crash but waitForReadyRead returns false(when there is something to read), or it takes (waitForReadyRead function) 100% of the CPU in a first thread before the segmentation fault in a second thread.

      The modified blocking fortune client and threaded fortune server examples can be used to reproduce the error (attached here). The amount of opened files (MAX_FILES in threadedfortuneserver/main.cpp) may need to be modified to be able to reproduce the crash. For me it was 1010 when running the example with gdb.

      The output from gdb:

      GLib-ERROR **: Cannot create pipe main loop wake-up: Too many open files

      aborting...

      #0 0xb7fe2430 in __kernel_vsyscall ()
      #1 0xb6c14651 in *__GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
      #2 0xb6c17a82 in *__GI_abort () at abort.c:92
      #3 0xb6b57026 in g_logv () from /lib/libglib-2.0.so.0
      #4 0xb6b57056 in g_log () from /lib/libglib-2.0.so.0
      #5 0xb6b4d1dd in ?? () from /lib/libglib-2.0.so.0
      #6 0xb6b4d274 in g_main_context_new () from /lib/libglib-2.0.so.0
      #7 0xb7082caf in QEventDispatcherGlibPrivate (this=0x8173ee0, context=0x0) at kernel/qeventdispatcher_glib.cpp:291
      #8 0xb7082ff0 in QEventDispatcherGlib (this=0x817dc20, parent=0x0) at kernel/qeventdispatcher_glib.cpp:338
      #9 0xb6f2b386 in QThreadPrivate::createEventDispatcher (data=0x8177890) at thread/qthread_unix.cpp:253
      #10 0xb6f2b4cd in QThreadPrivate::start (arg=0x8178b18) at thread/qthread_unix.cpp:305
      #11 0xb6e8596e in start_thread (arg=0xb65bab70) at pthread_create.c:300
      #12 0xb6cb7a4e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130

      Attachments

        1. threadedfortuneserver.zip
          11 kB
        2. server.c
          5 kB
        3. filesockets.tar.gz
          6 kB

        Issue Links

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

          Activity

            People

              Unassigned Unassigned
              qtcomsupport Qt Support
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes