id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc
109283,"Stack overflow, 100% CPU usage",dastapov@…,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:

[23598]   HTTP/1.1 200 OK
[23598]   Date: Tue, 26 Oct 2010 21:10:17 GMT
[23598]   Server: Apache/2.2.9 (Debian) mod_python/3.3.1 Python/2.5.2
[23598]   Last-Modified: Tue, 26 Oct 2010 21:00:52 GMT
[23598]   ETag: ""1888003-20a279-4938b67706900""
[23598]   Accept-Ranges: bytes
[23598]   Content-Type: application/x-tar
[23598]   Connection: close
[23598]   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.
",defect,new,major,,component1,,,,
