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

QUdpSocket write causes SEGFAULT after connectToHost

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.6.0 RC
    • 5.5.0
    • Network: Sockets
    • None
    • OS X 10.10.4
    • 0872156559dd290e8e940d22a89cb95a46ef0cf6

    Description

      QUdpSocket::write() causes a SEGFAULT after:

      • connecting the socket with connectToHost() with a hostname
      • not waiting with waitForConnected()
      • instead calling write()

      The SEGV occurs irrespective of whether an event loop is running or not. Calling connectToHost() with an IP address causes no SEGV. Therefore, I presume there is a race condition with hostname lookup. Hence, I'm calling write() on an unconnected socket, which is not supported, quoting from the QUdpSocket Docs:

      If you want to use the standard QIODevice functions read(), readLine(), write(), etc., you must first connect the socket directly to a peer by calling connectToHost().

      However, I expected write() to fail and return false, not to segfault.
      Using signals/slots this is obviously no issue, since the connected() signal is emitted after the connection is established and everything is fine.

      I have attached a test case. An event loop can be started if the EVENLOOP macro is defined. The error occurs irrespective of this define. The error only occurs if both HOSTNAME and NOWAIT are defined. Comment either and the error does not occur.

      Attachments

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

        Activity

          People

            alex1973tr Alex Trotsenko
            aer2aei Hannes Weisbach
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes