Bug 582162

Summary: XSP2 crashes serving static images
Product: [Mono] Mono: Runtime Reporter: Santiago Corredoira <santiago>
Component: io-layerAssignee: Rodrigo Kumpera <rkumpera>
Status: RESOLVED FIXED QA Contact: Mono Bugs <mono-bugs>
Severity: Normal    
Priority: P5 - None CC: jason.height, tagdev
Version: 2.6.x   
Target Milestone: ---   
Hardware: x86   
OS: Windows Vista   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on:    
Bug Blocks: 582827    
Attachments: xsp-test.tar.bz2

Description Santiago Corredoira 2010-02-23 11:58:18 UTC
Hi,

Requesting a simple HTML page with a jpg image makes XSP2 crash. If I remove the image from the HTML then the page is served OK all the time.

The version is XSP2 2.0 mono 2.6.1. the version 2.4.2.2 in the same machine works fine. 

I have tested it in two different machines, both Windows Vista Business SP1.

To make it easier to test I have uploaded a simple html and a image that makes it crash: http://www.sclsoftware.com/downloads/monotest.zip

To reproduce the problem this are the steps:

1. uncompress the zip file.
2. right click the extracted monoTest folder and click "XSP 2.0 Web Server Here 2.6.1"
3. open a browser and navigate to http://localhost:8080/text.html
4. Normally the first time the page is served correctly. Press reload a few times. The web server crashes usually the first or second reload.

I posted the problem in http://stackoverflow.com/questions/2305828/xsp2-crashes-serving-static-images and another user has the same problem.

This is the stack trace displayed by the console: (The line in Spanish says "it has been forced the interruption of an existing connection by the remote host")

Peer unexpectedly closed the connection on write. Closing our end. 
System.IO.IOException: Write failure ---> System.Net.Sockets.SocketException: Se 
 ha forzado la interrupción de una conexión existente por el host remoto. 
 
  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 un 
known>: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
Comment 1 Marek Habersack 2010-02-23 18:05:46 UTC
The issue is reproducible on Windows (7 in my case), everything works fine on Linux. Please do not boost the severity to Major, though - it won't make the solution faster. Thanks!
Comment 2 Santiago Corredoira 2010-02-24 10:27:49 UTC
OK, this is my first bug filled and since it makes the web server unusable I thought it was Mayor. Sorry!
Comment 3 Tiaan Geldenhuys 2010-04-27 17:10:54 UTC
This bug report seems to be a specific example of the general problem described under Bug 582827 (XSP 2.6.1 sends static content twice or crash on Windows)
Comment 4 Marek Habersack 2010-05-26 23:05:27 UTC
Another stack trace (xsp/trunk with mono 2.6.4 on Windows 7):

C:\temp\xsp\test>mono ..\xsp.exe --port 8081
xsp
Listening on address: 0.0.0.0
Root directory: C:\temp\xsp\test
Listening on port: 8081 (non-secure)
Hit Return to stop the server.
Handling exception type SynchronizationLockException
Message is Failed to regain lock
IsTerminating is set to True
System.Threading.SynchronizationLockException: Failed to regain lock
  at (wrapper managed-to-native) System.Threading.Monitor:Monitor_wait (object,i
nt)
  at System.Threading.Monitor.Wait (System.Object obj, Int32 millisecondsTimeout
) [0x00000] in <filename unknown>:0
  at System.Threading.Timer+Scheduler.SchedulerThread () [0x00000] in <filename
unknown>:0
Comment 5 Marek Habersack 2010-05-26 23:08:15 UTC
And another one:

C:\temp\xsp\test>mono ..\xsp.exe --port 8081
xsp
Listening on address: 0.0.0.0
Root directory: C:\temp\xsp\test
Listening on port: 8081 (non-secure)
Hit Return to stop the server.
Peer unexpectedly closed the connection on write. Closing our end.
System.IO.IOException: Write failure ---> System.Net.Sockets.SocketException: An
 operation was attempted on something that is not a socket.

  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
Comment 6 Marek Habersack 2010-05-26 23:13:09 UTC
Created attachment 365036 [details]
xsp-test.tar.bz2

This is the binary I used to obtain the above two traces. Compiled with vs2010 for .NET 3.5, ran with mono 2.6.4. Works fine with .NET. To reproduce the issue you need to reload the test site several times. XSP also may lock up on exit.
Comment 7 Rodrigo Kumpera 2010-06-01 20:37:30 UTC
Fixed the shutdown crash in r158302.

This will be featured in 2-6-5.
Comment 8 Rodrigo Kumpera 2010-06-01 20:47:14 UTC
The rest of the bug is due to some mess up with possibly stall handles.
Comment 9 Rodrigo Kumpera 2010-06-02 20:51:30 UTC
Marek Habersack fixed it on trunk/2-6 on r158326/r158327.
Comment 10 Robert Jordan 2010-06-03 12:25:05 UTC
*** Bug 582827 has been marked as a duplicate of this bug. ***
Comment 11 Robert Jordan 2010-06-03 12:26:19 UTC
*** Bug 602230 has been marked as a duplicate of this bug. ***