Bug 582827 - XSP 2.6.1 sends static content twice or crash on Windows
Summary: XSP 2.6.1 sends static content twice or crash on Windows
Status: RESOLVED DUPLICATE of bug 582162
Alias: None
Product: Mono: Tools
Classification: Mono
Component: XSP (show other bugs)
Version: 2.6.x
Hardware: 64bit Windows Vista
: P5 - None : Normal
Target Milestone: ---
Assignee: Marek Habersack
QA Contact: Marek Habersack
URL:
Whiteboard:
Keywords:
Depends on: 582162
Blocks:
  Show dependency treegraph
 
Reported: 2010-02-24 18:01 UTC by Tiaan Geldenhuys
Modified: 2010-06-03 12:25 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tiaan Geldenhuys 2010-02-24 18:01:46 UTC
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB6 (.NET CLR 3.5.30729)

When running XSP 2.6.1 on Windows and then requesting any static resource, such as a CSS file or PNG image, the server would attempt to send the data twice in the HTTP content of the response.  The Content-Length header indicates the correct size, which is half of what XSP would attempt to send.  If the HTTP client accepts all the content, XSP remains running but double the bandwidth is then used. However, if the client disconnects while receiving the duplicate half of the content (since, after all, it only expects to get Content-Length bytes), the XSP server would crash from an unhandled SocketException/ObjectDisposedException error.  On Linux this works fine though; the Windows version on which this bug was discovered is Vista (SP2, 64-bit).


Reproducible: Always

Steps to Reproduce:
1. Create a text file named "static.txt" in the root directory of your website, which could contain the string "This is some test content."
2. Run XSP from that directory (on Windows), which would serve the static file for example at "http://localhost:8080/static.txt"
3. Use a low-level TCP client to see what happens when you request the static resource.  For example, use "telnet localhost 8080" and then type the following HTTP request (remember to add a third blank line)...
GET /static.txt HTTP/1.1
Host: localhost:8080

4. Look at the response coming back from the XSP server.

Actual Results:  
The content contains the static text twice, and Content-Length is only half of what is being sent back...

HTTP/1.0 200 OK
Date: Sat, 20 Feb 2010 16:10:54 GMT
Server: Mono.WebServer2/0.2.0.0 Win32NT
Last-Modified: Sat, 20 Feb 2010 16:09:18 GMT
X-AspNet-Version: 2.0.50727
Content-Length: 26
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive

This is some test content.This is some test content.



Expected Results:  
The content must contain the static text only once...

HTTP/1.0 200 OK
Date: Sat, 20 Feb 2010 16:10:54 GMT
Server: Mono.WebServer2/0.2.0.0 Win32NT
Last-Modified: Sat, 20 Feb 2010 16:09:18 GMT
X-AspNet-Version: 2.0.50727
Content-Length: 26
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive

This is some test content.



See below for an example stack dump if the web client were to terminate the connection while the duplicate content is still being sent back from the server.  This can easily be reproduced with a real website running XSP on Windows, which would for example contain background images and CSS files, and when navigating through the site with a browser like Firefox.  Also, simply adding additional try-catch logic to the problematic code in "XSPWorker.cs", so that Close would not get called if the exception is of type ObjectDisposedException (attempting to close the disposed stream is what causes XSP to crash), only solves the crashing aspect of the problem, but XSP shouldn't be sending the duplicate content in the first place.  Even with such extra try-catch logic, some of the static resources still never show up on the browser after a full page refresh (Ctrl+F5), perhaps as a result of the bad logical state of the TCP connection.

Peer unexpectedly closed the connection on write. Closing our end.
System.IO.IOException: Write failure ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed
 by the remote host.
  at System.Net.Sockets.Socket.Send (System.Byte[] buf, Int32 offset, Int32 size, SocketFlags flags) [0x00000] in <filename unknown>:0
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0
  at Mono.WebServer.XSPWorker.Write (System.Byte[] buffer, Int32 position, Int32 size) [0x00000] in <filename unknown>:0
Peer unexpectedly closed the connection on write. Closing our end.
System.ObjectDisposedException: The object was used after being disposed.
  at System.Net.Sockets.NetworkStream.CheckDisposed () [0x00000] in <filename unknown>:0
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0
  at Mono.WebServer.XSPWorker.Write (System.Byte[] buffer, Int32 position, Int32 size) [0x00000] in <filename unknown>:0


Having investigated this a bit more, the following might be the call stack from where the duplicate content gets sent, but I'm not quite sure...

Mono.WebServer.MonoWorkerRequest.SendResponseFromFile(IntPtr handle, Int64 offset, Int64 length)
Mono.WebServer.XSPWorkerRequest.SendResponseFromFile(IntPtr handle, Int64 offset, Int64 length)
Mono.WebServer.XSPWorkerRequest.SendResponseFromFile(String filename, Int64 offset, Int64 length)
System.Web.HttpResponseStream+BufferedFileBucket.Send(HttpWorkerRequest wr)
System.Web.HttpResponseStream.Flush(HttpWorkerRequest wr, Boolean final_flush)
System.Web.HttpResponse.Flush(Boolean final_flush)
System.Web.HttpResponse.TransmitFile(String filename, Boolean final_flush)
System.Web.StaticFileHandler.ProcessRequest(HttpContext context)
System.Web.HttpApplication+<Pipeline>c__Iterator5.MoveNext()
System.Web.HttpApplication.Tick()
System.Web.HttpApplication.Start(Object x)
System.Web.HttpApplication.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
System.Web.HttpRuntime.Process(HttpWorkerRequest req)
System.Web.HttpRuntime.RealProcessRequest(Object o)
System.Web.HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
Mono.WebServer.MonoWorkerRequest.ProcessRequest()
Mono.WebServer.BaseApplicationHost.ProcessRequest(MonoWorkerRequest mwr)
Mono.WebServer.XSPApplicationHost.ProcessRequest(Int32 reqId, IPEndPoint localEP, IPEndPoint remoteEP, String verb, String path, String queryString, String protocol, Byte[] inputBuffer, String redirect, IntPtr socket, SslInformations ssl)
Mono.WebServer.XSPWorker.RunInternal(Object state)
Comment 1 Marek Habersack 2010-02-24 18:24:29 UTC
Tiaan, thanks for the report but please do not set the priority to Critical on any bugs. Please leave setting the priority/severity to the QA or Mono developers. This bug doesn't affect the majority of users (since Mono is used under Unix the most) so it cannot be critical in any way. I will investigate the issue before the end of this week.
Comment 2 Tiaan Geldenhuys 2010-02-24 19:03:21 UTC
@Marek: Sure, I actually agree that it's not all that "Critical", but the classification criteria are confusing.  Perhaps one could give more guidance about this on the bug submission form or document this in more detail on the "Accessibility: Bug Specification" page; after all, the drop-down selection only says "Critical: The software crashes [..., blah, blah]", which technically does apply in this case.  But as a rule of thumb, I'll try not to log other bugs as Critical.  :)  Thanks for intending to look at this soon enough and being so responsive and helpful.
Comment 3 Marek Habersack 2010-02-24 19:09:17 UTC
Generally, we leave the decision on bug priority/severity to the QA team - it all depends on where in the release cycle we are, what is the Mono developer's/maintainer's assessment of the bug's impact on Mono etc. In general - it's best to leave it alone when filing bug reports :)
Comment 4 Tiaan Geldenhuys 2010-03-11 14:26:32 UTC
Any chance this regression would be fixed for 2.6.3, or would 2.4.3 have to do for a few more months?
Comment 5 Tiaan Geldenhuys 2010-04-27 17:10:02 UTC
This bug report seems to describe the general case for Bug 582162 (XSP2 crashes serving static images).  

Also, versions 2.6.3 and 2.6.4 still have this problem, such that it continues to hamper migration testing.
Comment 6 Robert Jordan 2010-06-03 12:25:04 UTC
Mark as duplicate.

*** This bug has been marked as a duplicate of bug 582162 ***