Author Topic: Mac-specific bug (crash) in NATCompleteClient Sample  (Read 18544 times)

Trevor

  • Jr. Member
  • **
  • Posts: 77
  • Karma: 2
    • View Profile
    • LackeyCCG: Play any CCG online
Mac-specific bug (crash) in NATCompleteClient Sample
« on: July 04, 2014, 07:58:03 AM »
I've encountered an apparent bug that only appears in the mac version of NATCompleteClient.
Here is a sample Xcode project with the code from NATCompleteClient. http://www.lackeyccg.com/RakNet/NATCompleteClient.zip
Here is just the executable: http://www.lackeyccg.com/RakNet/NATCompleteClientExecutable.zip
I made no changes to the sample code.

To see the bug, run 2 instances of the executable. For the first instance, use all the default IPs and ports, say "y" to having a NATComplete Server running, and then have have it listen. For the second instance, I found that it is necessary to change the default local port if you're also testing the other instance on the same machine. And instead of listening, I entered the reported GUID from the first instance so that I could connect to it. This causes both instances to crash.

1st instance of the executable reports:
Code: [Select]
trevor:~ trevor$ /Users/trevor/Desktop/Files/NATCompleteClient ; exit;
Enter local port, or press enter for default:
NAT traversal client
Supported operations:

UPNPFramework
Requires server: No
Description: Use UPNP to open the router

NatTypeDetectionFramework
Requires server: Yes
Description: Determines router type to avoid NAT punch attempts that cannot
succeed.

NatPunchthoughClientFramework
Requires server: Yes
Description: Causes two systems to try to connect to each other at the same
time, to get through routers.

Router2Framework
Requires server: No
Description: Connect to a peer we cannot directly connect to using the
bandwidth of a shared peer.

UDPProxyClientFramework
Requires server: Yes
Description: Connect to a peer using a shared server connection.

Do you have a server running the NATCompleteServer project? (y/n):
Executing UPNPFramework

Failed UPNPFramework
Proceeding to next stage.
Executing NatTypeDetectionFramework

Failed NatTypeDetectionFramework
Proceeding to next stage.
Executing NatPunchthoughClientFramework
Enter IP of system NatPunchthroughServer, or press enter for default:
Enter port of system NatPunchthroughServer, or press enter for default:
Connecting...
Enter RakNetGuid of the remote system, which should have already connected
to the server.
Or press enter to just listen.

Listening
My GUID is 1404477264336045
Calculating port stride from 66.118.161.138|61111
HAS_PORT_STRIDE 0. First external port 50000. Second external port 50000.
Segmentation fault: 11
logout

2nd instance of the executable reports:
Code: [Select]
trevor:~ trevor$ /Users/trevor/Desktop/Files/NATCompleteClient ; exit;
Enter local port, or press enter for default: 12345
NAT traversal client
Supported operations:

UPNPFramework
Requires server: No
Description: Use UPNP to open the router

NatTypeDetectionFramework
Requires server: Yes
Description: Determines router type to avoid NAT punch attempts that cannot
succeed.

NatPunchthoughClientFramework
Requires server: Yes
Description: Causes two systems to try to connect to each other at the same
time, to get through routers.

Router2Framework
Requires server: No
Description: Connect to a peer we cannot directly connect to using the
bandwidth of a shared peer.

UDPProxyClientFramework
Requires server: Yes
Description: Connect to a peer using a shared server connection.

Do you have a server running the NATCompleteServer project? (y/n):
Executing UPNPFramework

Failed UPNPFramework
Proceeding to next stage.
Executing NatTypeDetectionFramework

Failed NatTypeDetectionFramework
Proceeding to next stage.
Executing NatPunchthoughClientFramework
Enter IP of system NatPunchthroughServer, or press enter for default:
Enter port of system NatPunchthroughServer, or press enter for default:
Connecting...
Enter RakNetGuid of the remote system, which should have already connected
to the server.
Or press enter to just listen.
1404477264336045        
Calculating port stride from 66.118.161.138|61111
HAS_PORT_STRIDE 0. First external port 12345. Second external port 12345.
Starting ID_NAT_PUNCHTHROUGH_REQUEST to guid 1404477264336045.
Segmentation fault: 11
logout

The crash happens on line 821 of main.cpp, which is:
Code: [Select]
for (packet=rakPeer->Receive(); packet; rakPeer->DeallocatePacket(packet), packet=rakPeer->Receive())Specifically, the rakPeer->Receive() part causes the crash.

I think this must be a bug with some RakNet code, either with the NATCompleteClient sample or the RakNet library. And it seems to only affect the mac version. I ran the same code on windows and it worked fine.

With a windows computer and a mac computer, both on the same LAN, a NAT Punch through attempt caused the mac version to crash (due to the same reason) while the windows version did not crash, so this issue cannot be the result of 2 executables being run on the same machine.

Can someone please confirm they also get this crash on the mac version (or if it works for you)? Does anyone know the mac-specific fix?
« Last Edit: July 04, 2014, 12:05:04 PM by Trevor »