[Mono-bugs] [Bug 32054][Nor] New - Sockets are sometimes garbage collected while still in use

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
10 Oct 2002 09:09:57 -0000


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by timothyjmills@hotmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=32054

--- shadow/32054	Thu Oct 10 05:09:57 2002
+++ shadow/32054.tmp.12037	Thu Oct 10 05:09:57 2002
@@ -0,0 +1,79 @@
+Bug#: 32054
+Product: Mono/Runtime
+Version: unspecified
+OS: Red Hat 7.2
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: timothyjmills@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Sockets are sometimes garbage collected while still in use
+
+Description of Problem:
+
+Sockets are sometimes garbage collected while still in use under Linux, 
+when used with NetworkStream BeginRead.
+
+
+Steps to reproduce the problem:
+1. compile SocketGCBug.cs (attached) and run 
+2. Repeat the following:
+      telnet localhost 9000
+      type in some junk and hit return
+
+Actual Results:
+
+After a few iterations, an exception will be thrown on Write
+
+[stockley@catnep Bug]$ CAUGHT EXCEPTION 
+System.Net.Sockets.SocketException: The
+descriptor is not a socket
+in (unmanaged) 06 System.Net.Sockets.Socket:Send_internal (intptr,byte
+[],int,int
+,System.Net.Sockets.SocketFlags)
+in <0x00004> 06 System.Net.Sockets.Socket:Send_internal (intptr,byte
+[],int,int,S
+ystem.Net.Sockets.SocketFlags)
+in <0x0008c> 00 System.Net.Sockets.Socket:Send (byte
+[],int,int,System.Net.Socket
+s.SocketFlags)
+in <0x000b0> 00 System.Net.Sockets.Socket:Send (byte
+[],int,int,System.Net.Socket
+s.SocketFlags)
+in <0x000c3> 00 System.Net.Sockets.NetworkStream:Write (byte[],int,int)
+
+GetMessage: caught System.IO.IOException: Write failure
+in <0x0013f> 00 System.Net.Sockets.NetworkStream:Write (byte[],int,int)
+in <0x000f0> 00 .SocketGCBug:GetMessage (System.IAsyncResult)
+
+
+Expected Results:
+Should always echo back input.  This works under Windows both using MS csc 
+and Mono mcs.
+
+How often does this happen? 
+Always, once enough garbage has been generated.
+
+Additional Information:
+Putting debugging in System.Socket.Close and System.Socket.Finalize shows 
+that the generation of a large amount of garbage triggers the GC to 
+collect the in-use socket.
+
+       at System.Net.Sockets.Socket.Close()
+       at System.Net.Sockets.Socket.Dispose()
+       at System.Net.Sockets.Socket.Finalize()
+       at System.Net.Sockets.Socket.Finalize()
+       at System.String..ctor()
+       at System.String..ctor()
+       at System.IntegerFormatter.FormatGeneral()
+       at SocketGCBug.GetMessage()
+       at System.MulticastDelegate.invoke_void_IAsyncResult()
+       at System.Net.Sockets.Socket+Worker.End()
+       at System.Net.Sockets.Socket+Worker.Receive()