[Mono-bugs] [Bug 77747][Nor] New - Two identical UnixEndPoints
instances are not equal
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Thu Mar 9 13:54:47 EST 2006
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 phbaer at npw.net.
http://bugzilla.ximian.com/show_bug.cgi?id=77747
--- shadow/77747 2006-03-09 13:54:47.000000000 -0500
+++ shadow/77747.tmp.2228 2006-03-09 13:54:47.000000000 -0500
@@ -0,0 +1,75 @@
+Bug#: 77747
+Product: Mono: Class Libraries
+Version: 1.1
+OS:
+OS Details: Ubuntu Breeze/Dapper i386/amd64
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Mono.POSIX
+AssignedTo: miguel at ximian.com
+ReportedBy: phbaer at npw.net
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Two identical UnixEndPoints instances are not equal
+
+Description of Problem:
+ 1) The hash code returned by a UnixEndPoint instance is not based on the
+actual endpoint (i.e. filename) but is the default hash for object (i.e. is
+independent of the filename). The hash generated by IPEndPoint, for
+example, is based in the IP address and the port number.
+
+ 2.1) The filename that is returned by a libc recvfrom call contains a
+trailing zero (for normal endpoints, the filename should be zero
+terminated). This zero is passed to the .net string. In my patch, this zero
+ is removed. The trailing zero must be removed in order to be able to
+calculate a valid and unique hash, which in turn is vital for adding to
+hashlists, etc.
+
+ 2.2) The filename from which a UnixEndPoint is created does not include a
+trailing zero. The socket address (sockaddr_un), however, required the
+filename to be zero terminated, given a non-abstract namespace is required.
+
+
+Steps to reproduce the problem:
+ 0) Please see ftp://npw.net/pub/phbaer/mono/UnixEndPoint/
+
+ 1.1) Create two UnixEndPoint with the same filename (uep1, uep2)
+ 1.2) "uep1.Equals(uep2)" returns "false"
+
+ 2.1) Create a server listening on a unix domain socket
+ 2.2) Create a client listening on another unix domain socket
+ 2.3 Use ReceiveFrom in the server to wait for data from the client
+ 2.3) Send som data from the client to the server
+ 2.4) Check the EndPoint returned by ReceiveFrom, it will contain three
+trailing zeros.
+ 2.5) The received endpoint will not equal the endpoint the client listens
+to, if the comparison is based on the filename (which is the actual
+endpoint an should thus be compared)
+
+
+Actual Results:
+ $ ./Hash.exe
+ UnixEndPoint Equals? False 144414976 1593857088
+ IPEndPoint Equals? True 16789688 16789688
+ 2f 74 6d 70 2f 74 65 73 74
+ 2f 74 6d 70 2f 74 65 73 74 31 0 0 0
+
+Expected Results:
+ $ ./Hash.exe
+ UnixEndPoint Equals? True 144414976 144414976
+ IPEndPoint Equals? True 16789688 16789688
+ 2f 74 6d 70 2f 74 65 73 74
+ 2f 74 6d 70 2f 74 65 73 74 31
+
+How often does this happen?
+ Always
+
+Additional Information:
+ A patch that solved this problem is available at
+ ftp://npw.net/pub/phbaer/mono/UnixEndPoint/
+
+ It's not so beatiful but works for me :)
More information about the mono-bugs
mailing list