[Mono-bugs] [Bug 82449][Blo] New - Socket GetHashCode relies on the OS handle which once disposed is no longer valid

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Aug 15 12:40:28 EDT 2007


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 davidiw at ufl.edu.

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

--- shadow/82449	2007-08-15 12:40:28.000000000 -0400
+++ shadow/82449.tmp.19032	2007-08-15 12:40:28.000000000 -0400
@@ -0,0 +1,73 @@
+Bug#: 82449
+Product: Mono: Class Libraries
+Version: 1.2
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 001 One hour
+Priority: Blocker
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: davidiw at ufl.edu               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Socket GetHashCode relies on the OS handle which once disposed is no longer valid
+
+Description of Problem:
+Socket GetHashCode relies on the OS handle which once disposed is no longer
+valid
+
+Hashtable ht = new Hashtable();
+Socket s = new Socket(...);
+ht[s] = 5;
+Console.WriteLine(ht.Contains(s)); // true
+s.Close();
+Console.WriteLine(ht.Contains(s)); // false
+
+Actual Results:
+
+
+Expected Results:
+The second Console.WriteLine should be true
+
+How often does this happen? 
+Every
+
+The patch below was provided by Robert Jordan
+
+Index: System.Net.Sockets/ChangeLog
+===================================================================
+--- System.Net.Sockets/ChangeLog	(revision 84012)
++++ System.Net.Sockets/ChangeLog	(working copy)
+@@ -1,3 +1,7 @@
++2007-08-13   Robert Jordan  <robertj at gmx.net>
++
++	* Socket.cs: Remove 2.0 GetHashCode overload.
++
+ 2007-08-02  Dick Porter  <dick at ximian.com>
+ 
+ 	* Socket.cs: Patch from Brian Nickel (brian.nickel at gmail.com) to
+Index: System.Net.Sockets/Socket.cs
+===================================================================
+--- System.Net.Sockets/Socket.cs	(revision 84012)
++++ System.Net.Sockets/Socket.cs	(working copy)
+@@ -3240,10 +3240,16 @@
+ 				throw new SocketException (error);
+ 		}
+ 
++#if ONLY_1_1
+ 		public override int GetHashCode ()
+ 		{
++			// LAMESPEC:
++			// The socket is not suitable to serve as a hash code,
++			// because it will change during its lifetime, but
++			// this is how MS.NET 1.1 implemented this method.
+ 			return (int) socket; 
+ 		}
++#endif
+ 
+ 		protected virtual void Dispose (bool explicitDisposing)
+ 		{


More information about the mono-bugs mailing list