<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2658.2">
<TITLE>Framented packet bug ?</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2 FACE="Lucida Console">Hello.</FONT>
</P>

<P><FONT SIZE=2 FACE="Lucida Console">I have a client connected to a server, and I make the client send a 32K text to the server.</FONT>
<BR><FONT SIZE=2 FACE="Lucida Console">Upon receiving the first fragment, the server crashes. The callstack is as follows:</FONT>
</P>

<P><FONT SIZE=1 FACE="Lucida Console">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TestTravelStuff.exe!enet_peer_queue_incoming_command(_ENetPeer * peer=0x003a11b8, const ENetProtocol * command=0x00abf964, _ENetPacket * packet=0x003a5b80, unsigned int fragmentCount=25)&nbsp; Line 559&nbsp;&nbsp;&nbsp; C</FONT></P>

<P><FONT SIZE=1 FACE="Lucida Console">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TestTravelStuff.exe!enet_protocol_handle_send_fragment(_ENetHost * host=0x003a4190, _ENetPeer * peer=0x003a11b8, const ENetProtocol * command=0x003a4a68)&nbsp; Line 414 + 0x25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C</FONT></P>

<P><FONT SIZE=1 FACE="Lucida Console">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TestTravelStuff.exe!enet_protocol_handle_incoming_commands(_ENetHost * host=0x003a4190, _ENetEvent * event=0x00abfe70)&nbsp; Line 748 + 0x11 C</FONT></P>

<P><FONT SIZE=1 FACE="Lucida Console">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TestTravelStuff.exe!enet_protocol_receive_incoming_commands(_ENetHost * host=0x003a4190, _ENetEvent * event=0x00abfe70)&nbsp; Line 816 + 0xd C</FONT></P>

<P><FONT SIZE=1 FACE="Lucida Console">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TestTravelStuff.exe!enet_host_service(_ENetHost * host=0x003a4190, _ENetEvent * event=0x00abfe70, unsigned int timeout=285188939)&nbsp; Line 1267 + 0xd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C</FONT></P>

<P><FONT SIZE=1 FACE="Lucida Console">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TestTravelStuff.exe!CTravelServer::Tick(float _date=285188.94)&nbsp; Line 1101 + 0x12&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C++</FONT>
<BR><FONT SIZE=1 FACE="Lucida Console">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TestTravelStuff.exe!threadProc(void * _lpParameter=0x0012fec8)&nbsp; Line 463 + 0x17 C++</FONT>
<BR><FONT SIZE=1 FACE="Lucida Console">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kernel32.dll!77e5d28e() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
</P>

<P><FONT SIZE=2 FACE="Lucida Console">The packet that the server receives is a</FONT> <FONT SIZE=1 FACE="Lucida Console">ENET_PROTOCOL_COMMAND_SEND_FRAGMENT,</FONT><FONT SIZE=2 FACE="Lucida Console"> but in</FONT><FONT SIZE=2 FACE="Lucida Console"></FONT> <FONT SIZE=1 FACE="Lucida Console">enet_peer_queue_incoming_command</FONT><FONT SIZE=2 FACE="Lucida Console">, there is a switch that captures only</FONT> <FONT SIZE=1 FACE="Lucida Console">ENET_PROTOCOL_COMMAND_SEND_RELIABLE</FONT><FONT SIZE=2 FACE="Lucida Console">,</FONT> <FONT SIZE=1 FACE="Lucida Console">ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE</FONT><FONT SIZE=2 FACE="Lucida Console">, and</FONT> <FONT SIZE=1 FACE="Lucida Console">ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED</FONT><FONT SIZE=2 FACE="Lucida Console">. This causes the function to destroy the packet that was created to receive the reunited fragments, and to return NULL. Then,</FONT> <FONT SIZE=1 FACE="Lucida Console">enet_protocol_handle_send_fragment</FONT> <FONT SIZE=2 FACE="Lucida Console">crashes, because it didn't expect that</FONT><FONT SIZE=1 FACE="Lucida Console">.</FONT></P>

<P><FONT SIZE=2 FACE="Lucida Console">I suppose that ENet needs to handle properly the</FONT> <FONT SIZE=1 FACE="Lucida Console">ENET_PROTOCOL_COMMAND_SEND_FRAGMENT</FONT><FONT SIZE=2 FACE="Lucida Console"> command. But then, what should be the proper handling here ?</FONT></P>
<BR>
<BR>

<P><FONT COLOR="#800000" SIZE=2 FACE="Lucida Console">__________________________________</FONT>
<BR><FONT COLOR="#800000" SIZE=2 FACE="Lucida Console">Benoit Germain</FONT>
<BR><A HREF="mailto:bgermain@ubisoft.fr"><U></U><U><FONT COLOR="#0000FF" SIZE=2 FACE="Lucida Console">mailto:bgermain@ubisoft.fr</FONT></U></A>
</P>

<P><FONT COLOR="#660000" SIZE=2 FACE="Lucida Console">Person who says it cannot be done should not interrupt person doing it.</FONT>
<BR><FONT COLOR="#660000" SIZE=2 FACE="Lucida Console">-- Chinese Proverb</FONT>
</P>

<P><FONT COLOR="#800000" SIZE=2 FACE="Lucida Console">People who think they're smart annoy those of us who are.</FONT>
<BR><FONT COLOR="#800000" SIZE=2 FACE="Lucida Console">-- double-U's Proverb ?</FONT>
<BR><FONT COLOR="#800000" SIZE=2 FACE="Lucida Console">__________________________________</FONT>
</P>

</BODY>
</HTML>