[Qt-interest] A bug? Busy looping in QAbstractSocket triggered by full read buffer

Brendon Higgins blhiggins at gmail.com
Sat Dec 11 09:29:25 CET 2010


Hi list,

I think I might've found a bug, but I'm not familiar with code at this level, 
so I thought I'd better ask before making any accusations. :-)

In qabstractsocket.cpp, lines 1832--1859 are a "forever" loop, where the code 
apparently busily waits for data to arrive ready to read. Notice lines 
1849--1852. Let's assume readyToRead is true (also assume the socket is still 
connected). Line 1850 calls canReadNotification(), which (at line 608) returns 
false if the read buffer has no more space. So the busy loop will not exit at 
line 1851 like (presumably) it normally would. And since the socket is still 
connected, the loop does not terminate at line 1858, either (or at all). These 
conditions don't change---the buffer is not (cannot be) flushed by anything in 
this loop, AFAICT---so the loop never terminates (until the connection 
eventually times out, presumably).

I found this issue using KDE and downloading a large file from a nearby 
high-bandwidth server. The kio_http process stops downloading and starts using 
up 100%. Attaching gdb to the process, it appears to be busy looping in the 
aforementioned code.

Seems to me maybe there should be some sort of error emitted if the buffer is 
overrun, but that apparently isn't happening.

So, is this a bug, or are there subtleties I'm missing?

Peace,
Brendon



More information about the Qt-interest-old mailing list