(Case 1103998) XboxOneEndPoint + Unet = Majorly Broken

Basically, multiplayer with Unet using XboxOneEndPoint is totally broken. Works fine in 2018.2.

The error takes place in NetworkTransport.cs

2018.2 version:

76:  // Convert the byte[] pointer to an IntPtr
77:  IntPtr st = new IntPtr(BitConverter.ToInt64(dst, 0));
78:  if (st == IntPtr.Zero)
79:      throw new ArgumentException("XboxOneEndPoint has an invalid SOCKET_STORAGE pointer");
80:
81:  byte[] SocketAddressFamily = new byte[2]; // short
82:  System.Runtime.InteropServices.Marshal.Copy(st, SocketAddressFamily, 0, SocketAddressFamily.Length);
83: 
84:  System.Net.Sockets.AddressFamily a = (System.Net.Sockets.AddressFamily)((((int)SocketAddressFamily[1]) << 8) + (int)SocketAddressFamily[0]);
85:  if (a != System.Net.Sockets.AddressFamily.InterNetworkV6)
86:      throw new ArgumentException("XboxOneEndPoint has corrupt or invalid SOCKET_STORAGE pointer");

2018.3 version:

76:  byte[] SocketAddressFamily = new byte[2]; // short
77:  Buffer.BlockCopy(dst, 0, SocketAddressFamily, 0, SocketAddressFamily.Length);
78:
79:  System.Net.Sockets.AddressFamily a = (System.Net.Sockets.AddressFamily)((((int)SocketAddressFamily[1]) << 8) + (int)SocketAddressFamily[0]);
80:  if (a != System.Net.Sockets.AddressFamily.InterNetworkV6)
81:      throw new ArgumentException("XboxOneEndPoint has corrupt or invalid SOCKET_STORAGE pointer");

Basic issue is line 79 of 2018.3 version is performing an operation on the memory address.

2018.2 is performing the operation on the value at the memory address (See line 82 of 2018.2 version to where it reads the value of the memory)

This is happening on UWP build. I haven’t tested on Xbox One but I suppose it will break there as well.

Any idea on a time frame for this getting fixed? I’d love to be able to ship on 2018.3 because 2018.2 has a different show stopping bug that isn’t getting any attention but is fixed in 2018.3.

Having a look at this now.

So I’ve fixed this by reverting some of the code that was removed in 2018.3:

74:                // Convert the byte[] pointer to an IntPtr so we can marshal copy info from the underlying native socket object below
75:                IntPtr socketPointer = new IntPtr(BitConverter.ToInt64(dst, 0));
76:                if (socketPointer == IntPtr.Zero)
77:                    throw new ArgumentException("XboxOneEndPoint has an invalid SOCKET_STORAGE pointer");
78:
79:                // check that the socket pointed to by socketPointer has an address family of type IPv6
80:                byte[] SocketAddressFamily = new byte[2]; // short
81:                System.Runtime.InteropServices.Marshal.Copy(socketPointer, SocketAddressFamily, 0, SocketAddressFamily.Length); // copy over the first 2 bytes from the object pointed to by socketPointer
82:                System.Net.Sockets.AddressFamily a = (System.Net.Sockets.AddressFamily)((((int)SocketAddressFamily[1]) << 8) + (int)SocketAddressFamily[0]);
83:                if (a != System.Net.Sockets.AddressFamily.InterNetworkV6)
84:                    throw new ArgumentException("XboxOneEndPoint has corrupt or invalid SOCKET_STORAGE pointer");
85:
86:                // everything should be OK so call the internal function to begin the connect handshake to this socket
87:                return Internal_ConnectEndPoint(hostId, dst, kSockAddrStorageLength, exceptionConnectionId, out error);

This is now being PRed internally into the networking extension repo code and into 2018.3. I’m trying to hurry my PR along so it can get into the next 2018.3 release (which is currently being planned to be the first release candidate) so fingers crossed.

2 Likes