Author Topic: UDPForwarder crash  (Read 8506 times)

ANet

  • Full Member
  • ***
  • Posts: 166
  • Karma: 3
    • View Profile
UDPForwarder crash
« on: May 05, 2012, 12:19:35 AM »
Hello,

now I'm getting another issue with UDP proxy.

When I test it and request forwarding from one client to another for several times I get UDP server crashed.
Here is the call stack:

Quote
   RakNet_x86d.dll!_wassert(const wchar_t * expr, const wchar_t * filename, unsigned int lineno)  Line 325   C
    RakNet_x86d.dll!DataStructures::OrderedList<RakNet::UDPForwarder::SrcAndDest,RakNet::UDPForwarder::ForwardEntry *,&RakNet::UDPForwarder::SrcAndDestForwardEntryComp>::Insert(const RakNet::UDPForwarder::SrcAndDest & key, RakNet::UDPForwarder::ForwardEntry * const & data, bool assertOnDuplicate, const char * file, unsigned int line, int (const RakNet::UDPForwarder::SrcAndDest &, RakNet::UDPForwarder::ForwardEntry * const &)* cf)  Line 170 + 0x1a bytes   C++
   RakNet_x86d.dll!RakNet::UDPForwarder::UpdateThreaded_Old()  Line 274   C++
    RakNet_x86d.dll!RakNet::UpdateUDPForwarder(void * arguments)  Line 802   C++
    RakNet_x86d.dll!_callthreadstartex()  Line 314 + 0x6 bytes   C
    RakNet_x86d.dll!_threadstartex(void * ptd)  Line 292 + 0x5 bytes   C
    kernel32.dll!768f339a()    
    [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]   
    ntdll.dll!778e9ef2()    
    ntdll.dll!778e9ec5()    

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: UDPForwarder crash
« Reply #1 on: May 05, 2012, 09:36:43 AM »
What version is this, in RakNetVersion.h? You don't have the same code as me. But from the context it's probably this line asserting.
forwardList.Insert(forwardEntry->srcAndDest,forwardEntry,true,_FILE_AND_LINE_);

It means you are forwarding between two systems that have already been forwarded.

ANet

  • Full Member
  • ***
  • Posts: 166
  • Karma: 3
    • View Profile
Re: UDPForwarder crash
« Reply #2 on: May 10, 2012, 12:49:07 AM »
I use RakNet 4.037 (4/4/2012).

It seems that line numbers are messed up... I've rebuilt RakNet and NATCompleteServer several times, disabled code optimizations, but still receive incorrect line numbers.
Callstack shows on this line in UDPForwarder:

Code: [Select]
if (forwardEntry->srcAndDest.source.address.addr4.sin_addr.s_addr==sa.sin_addr.s_addr && forwardEntry->srcAndDest.source.GetPort()==portnum)

but it seems to crash inside Insert function.

I still get this error in the following case:
 1. Start NATCompleteServer (on windows computer), UDPForwarder is on localhost.
 2. Start NATCompleteClient (on linux computer, behind symmetric NAT)
 3. Start another NATCompleteClient (on another linux computer, behind symmetric NAT)

And repeat items 2-3 for several times (after successful connection between clients I quit both applications and restart).
After several retries I get this crash.

So,  yes, I request forwarding between 2 same systems for several times. But why the server crashes instead of returning error code that forwarding is already in progress?

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: UDPForwarder crash
« Reply #3 on: May 10, 2012, 09:09:44 AM »
See if the attached fixes it for you.

ANet

  • Full Member
  • ***
  • Posts: 166
  • Karma: 3
    • View Profile
Re: UDPForwarder crash
« Reply #4 on: May 11, 2012, 12:38:27 AM »
No, it didn't help :(
Still crashes.
Same callstack:
Quote
   NATCompleteServer.exe!_NMSG_WRITE(int rterrnum)  Line 217   C
    NATCompleteServer.exe!abort()  Line 61 + 0x7 bytes   C
    NATCompleteServer.exe!_wassert(const wchar_t * expr, const wchar_t * filename, unsigned int lineno)  Line 153   C
    NATCompleteServer.exe!DataStructures::OrderedList<RakNet::UDPForwarder::SrcAndDest,RakNet::UDPForwarder::ForwardEntry *,&RakNet::UDPForwarder::SrcAndDestForwardEntryComp>::Insert(const RakNet::UDPForwarder::SrcAndDest & key, RakNet::UDPForwarder::ForwardEntry * const & data, bool assertOnDuplicate, const char * file, unsigned int line, int (const RakNet::UDPForwarder::SrcAndDest &, RakNet::UDPForwarder::ForwardEntry * const &)* cf)  Line 170 + 0x1c bytes   C++
>   NATCompleteServer.exe!RakNet::UDPForwarder::UpdateThreaded_Old()  Line 315   C++
    NATCompleteServer.exe!RakNet::UpdateUDPForwarder(void * arguments)  Line 805   C++
    NATCompleteServer.exe!_callthreadstartex()  Line 314 + 0xf bytes   C
    NATCompleteServer.exe!_threadstartex(void * ptd)  Line 297   C


Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: UDPForwarder crash
« Reply #5 on: May 11, 2012, 10:03:53 PM »
Try the attached

ANet

  • Full Member
  • ***
  • Posts: 166
  • Karma: 3
    • View Profile
Re: UDPForwarder crash
« Reply #6 on: May 11, 2012, 11:45:37 PM »
I've tried to compile updated UDPForwarder, but I've got this error (I use Microsoft Visual C++ 2010 Express):

Quote
1>------ Build started: Project: LibStatic, Configuration: Debug Win32 ------
1>  UDPForwarder.cpp
1>d:\work\raknet\raknet_pc-4.037\source\udpforwarder.cpp(272): error C2664: 'DataStructures::OrderedList<key_type,data_type,default_comparison_function>::InsertAtIndex' : cannot convert parameter 1 from 'RakNet::UDPForwarder::SrcAndDest' to 'RakNet::UDPForwarder::ForwardEntry *const &'
1>          with
1>          [
1>              key_type=RakNet::UDPForwarder::SrcAndDest,
1>              data_type=RakNet::UDPForwarder::ForwardEntry *,
1>              default_comparison_function=int RakNet::UDPForwarder::SrcAndDestForwardEntryComp(const RakNet::UDPForwarder::SrcAndDest &,RakNet::UDPForwarder::ForwardEntry *const &)
1>          ]
1>          Reason: cannot convert from 'RakNet::UDPForwarder::SrcAndDest' to 'RakNet::UDPForwarder::ForwardEntry *const '
1>          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>d:\work\raknet\raknet_pc-4.037\source\udpforwarder.cpp(312): error C2664: 'DataStructures::OrderedList<key_type,data_type,default_comparison_function>::InsertAtIndex' : cannot convert parameter 1 from 'RakNet::UDPForwarder::SrcAndDest' to 'RakNet::UDPForwarder::ForwardEntry *const &'
1>          with
1>          [
1>              key_type=RakNet::UDPForwarder::SrcAndDest,
1>              data_type=RakNet::UDPForwarder::ForwardEntry *,
1>              default_comparison_function=int RakNet::UDPForwarder::SrcAndDestForwardEntryComp(const RakNet::UDPForwarder::SrcAndDest &,RakNet::UDPForwarder::ForwardEntry *const &)
1>          ]
1>          Reason: cannot convert from 'RakNet::UDPForwarder::SrcAndDest' to 'RakNet::UDPForwarder::ForwardEntry *const '
1>          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

To fix it I've replaced this line:
Code: [Select]
forwardList.InsertAtIndex(forwardEntry->srcAndDest,index,_FILE_AND_LINE_);

with this one:
Code: [Select]
forwardList.InsertAtIndex(forwardEntry,index,_FILE_AND_LINE_);

Is it correct?

It seems that now everything works fine. There are no crashes anymore!

ANet

  • Full Member
  • ***
  • Posts: 166
  • Karma: 3
    • View Profile
Re: UDPForwarder crash
« Reply #7 on: May 12, 2012, 01:07:03 AM »
I've got another crash:

Quote
   NATCompleteServer.exe!operator delete(void * pUserData)  Line 52 + 0x51 bytes   C++
    NATCompleteServer.exe!operator delete[](void * p)  Line 21 + 0x9 bytes   C++
>   NATCompleteServer.exe!RakNet::OP_DELETE_ARRAY<RakNet::SystemAddress>(RakNet::SystemAddress * buff, const char * file, unsigned int line)  Line 201 + 0x15 bytes   C++
    NATCompleteServer.exe!DataStructures::List<RakNet::SystemAddress>::~List<RakNet::SystemAddress>()  Line 140 + 0x15 bytes   C++
    NATCompleteServer.exe!RakNet::RakPeer::GetConnectionList(RakNet::SystemAddress * remoteSystems, unsigned short * numberOfSystems)  Line 1089 + 0x17 bytes   C++
    NATCompleteServer.exe!RakNet::CloudServerHelper::OnConnectionCountChange(RakNet::RakPeerInterface * rakPeer, RakNet::CloudClient * cloudClient)  Line 328 + 0x18 bytes   C++
    NATCompleteServer.exe!CloudServerFramework::ProcessPacket(RakNet::RakPeerInterface * rakPeer, RakNet::Packet * packet)  Line 381 + 0x10 bytes   C++
    NATCompleteServer.exe!main()  Line 539 + 0x2e bytes   C++
    NATCompleteServer.exe!__tmainCRTStartup()  Line 278 + 0x19 bytes   C
    NATCompleteServer.exe!mainCRTStartup()  Line 189   C

Reproduction was the same: I requested forwarding from 2 same systems for several times.

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: UDPForwarder crash
« Reply #8 on: May 12, 2012, 09:36:45 AM »
I'm guessing it's calling the destructor for one of the two lists in RakPeer::GetConnectionList but there's no way that can crash. Can you give me screenshots next time? Include all relevant levels of the callstack and variables.

ANet

  • Full Member
  • ***
  • Posts: 166
  • Karma: 3
    • View Profile
Re: UDPForwarder crash
« Reply #9 on: May 14, 2012, 01:40:05 AM »
Ok, I'll do.

Got the old crash with failed RakAssert(objectExists) with the last version of UDPForwarder.cpp. This time it took me much more time to reproduce it.

My version of UDPForwarder.cpp is slightly different because of these modification (lines 272-273 and 313-314):
Code: [Select]
//forwardList.InsertAtIndex(forwardEntry->srcAndDest,index,_FILE_AND_LINE_);
forwardList.InsertAtIndex(forwardEntry,index,_FILE_AND_LINE_);

ANet

  • Full Member
  • ***
  • Posts: 166
  • Karma: 3
    • View Profile
Re: UDPForwarder crash
« Reply #10 on: May 14, 2012, 01:40:45 AM »
One more callstack screenshot for a previous post.

ANet

  • Full Member
  • ***
  • Posts: 166
  • Karma: 3
    • View Profile
Re: UDPForwarder crash
« Reply #11 on: May 14, 2012, 02:23:01 AM »
Today I also got another issue.

Sometimes after several successful UDP proxy forwading requests UDPProxyCoordinator on server side stops answering. And does not answer until server is restarted.
Here is an error message I get:

Quote
No response from the server, probably not running UDPProxyCoordinator plugin.

Failed UDPProxyClientFramework
Connectivity not possible. Exiting

After I get this message NAT punchtrhough server does not answer either:

Quote
Starting ID_NAT_PUNCHTHROUGH_REQUEST to guid 18446744073372578087.
No response from the server, probably not running NatPunchthroughServer plugin.

Failed NatPunchthoughClientFramework
Proceeding to next stage.
Executing UDPProxyClientFramework
Enter RakNetGuid of the remote system, which should have already connected
to the server.
Or press enter to just listen.
18446744073372578087
No response from the server, probably not running UDPProxyCoordinator plugin.

Failed UDPProxyClientFramework
Connectivity not possible. Exiting

Full server and clients output are in attached files.

I've also attached list of threads running in NATCompleteServer (I've just pushed Ctrl^C after server stopped responding to look what NATCompleteServer was doing at that time). May be it can help.
« Last Edit: May 14, 2012, 02:34:30 AM by ANet »

ANet

  • Full Member
  • ***
  • Posts: 166
  • Karma: 3
    • View Profile
Re: UDPForwarder crash
« Reply #12 on: May 14, 2012, 02:40:27 AM »
2 more NATCompleteServer thread callstacks after it stopped answering

ANet

  • Full Member
  • ***
  • Posts: 166
  • Karma: 3
    • View Profile
Re: UDPForwarder crash
« Reply #13 on: May 14, 2012, 02:40:56 AM »
and 1 more that I could not attach to the previous post

ANet

  • Full Member
  • ***
  • Posts: 166
  • Karma: 3
    • View Profile
Re: UDPForwarder crash
« Reply #14 on: May 14, 2012, 03:02:47 AM »
That crash on list deletion I could not reproduce this time :(