Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.5.0
-
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
For Gerrit Dashboard: QTBUG-48356 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
127258,5 | QAbstractSocket: fix writing to socket in HostLookup state | 5.5 | qt/qtbase | Status: MERGED | +2 | 0 |