David Almroth
unread,Oct 15, 2010, 1:24:00 PM10/15/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to lidgren-network, pikk...@googlegroups.com
Hi master Lidgren,
I've done some extensive test with sending av receiving fragmented
messages over the unreliable channel.
In one of my tests i send the last fragment first.
This gives me a crash bug.
From what I can see this part of the code (lidgren generation 2)
is the problem.
As you can see below, the space for all fragmens' payload is allocated
based on the size of the first arriving
fragment. If the first arriving fragment is shorter than the rest of
the fragments the Array.Copy() in AcceptMessage(IncomingNetMessage
msg) will crash when the other fragments arrive later.
The last fragment is usually shorter than the other fragments. Make a
test and send the last (short) fragment first and you will see this
bug.
Code sample from NetConnection.Fragmentation.cs:
if (!m_fragments.TryGetValue(id, out fmsg))
{
m_owner.LogVerbose("Creating new FragmentMessage instance for id "
+ id);
fmsg = new FragmentedMessage();
fmsg.TotalFragments = total;
fmsg.FragmentsReceived = 0;
fmsg.ChunkSize = payloadLen;
fmsg.Data = new byte[payloadLen * total]; //This is the
problem !!!
m_fragments[id] = fmsg;
}
My suggestion for a solution is to discard the complete fragmented
message if the last fragment arrives first. Since it is sent as
unreliable, it is OK to discard it.
Best Regards
/David