Ticket #109283 (new defect)
Stack overflow, 100% CPU usage
|Reported by:||dastapov@…||Owned by:||somebody|
I am investigating a "cabal update" breaking down with "Stack overflow". I've tracked the problem to a particular line referencing "browse" from Network.Browser.
After browsing through old bugs I've taken the test code from #8, simplifying it the tiniest bit: http://hpaste.org/paste/9447/simplified_a_bit#p40904
I am using HTTP 4000.0.9
Using this test code I attempted to download a 58 Mb test file which is being served with the following headers:
 HTTP/1.1 200 OK  Date: Tue, 26 Oct 2010 21:10:17 GMT  Server: Apache/2.2.9 (Debian) mod_python/3.3.1 Python/2.5.2  Last-Modified: Tue, 26 Oct 2010 21:00:52 GMT  ETag: "1888003-20a279-4938b67706900"  Accept-Ranges: bytes  Content-Type: application/x-tar  Connection: close  Proxy-Connection: close
If I serve the file with "Content-Length: xxxx", problem goes away.
I added "setDebugLog ..." to my request and noticed that with Content-Length file is read in one go using "readBlock", and without Content-Length file is being read with "readLine".
In both cases full contents of the file is shown in debug log. In both cases "closeOnEnd" is suspiciously missing from debug log.
If I try to "writeFile" response body to disk, I would get the whole file if it was served with Content-Length, or I would get 2-4K of it immediately if it was server WITHOUT Content-Length. After that program would either report "Stack overflow" or (provided that I ran it with +RTS -K400m) it will consume 100% CPU, outputting 1-2K of the file every 5-60 seconds.