sampad1370 / lidgren-network

Automatically exported from code.google.com/p/lidgren-network
0 stars 1 forks source link

Frequent Exception "Recyling already recycled message! Thread race?" #36

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
using the latest gen3 download, I encountered frequent Exceptions
within the Heartbeat function by sending unconnected data between
two peers.
The exception occurs at NetPeer.MessagePools.cs, line 142:

throw new NetException("Recyling already recycled message! Thread race?");

My example is quite trivial, just two peers frequently sending and reading 
(unconnected) messages.

There is a counter m_recyclingCount, I found many locations, where this 
variable is updated and wondered if there might be a synchronisation problem...

The message, that causes the exception, is an outgoing message, perhaps there 
is some error:

NetOutgoingMessage msgOut = m_server.CreateMessage();
msgOut.Write(...);
m_server.Start();

while (true)
{
  ...
  m_server.SendUnconnectedMessage(msgOut, OtherEndpoint);
  msgIn = m_server.WaitMessage((int)m_waitMessageMillis);
  ...
}

What version of the product are you using? On what operating system?
Windows XP Professional SP2

Best regards

Dietmar

Original issue reported on code.google.com by texavery...@googlemail.com on 27 Jan 2011 at 3:54

GoogleCodeExporter commented 9 years ago
Turn off recycling and you should be fine; or better - upgrade to the gen3 
version.

Original comment by lidg...@gmail.com on 29 Jan 2011 at 3:32

GoogleCodeExporter commented 9 years ago
Oh... you seem to have posted the issue on the wrong version; you clearly mean 
gen3 code. I haven't seen this problem in any of the samples; I just checked in 
a very simple UnconnectedSample for which it does not occur. Do you call 
Recycle more than once?

Original comment by lidg...@gmail.com on 29 Jan 2011 at 3:38

GoogleCodeExporter commented 9 years ago
Oh, sorry for posting on the wrong version! 
Regarding the exception, I did not even call Recycle in my own code,
but noticed the exception thrown within the server thread (in function 
Heartbeat) frequently.
Maybe there was some kind of race condition on the OutgoingMessage instance...

Original comment by texavery...@googlemail.com on 29 Jan 2011 at 7:20

GoogleCodeExporter commented 9 years ago
I can't repro with the samples; can you upload your code somewhere so I can 
test it?

Original comment by lidg...@gmail.com on 29 Jan 2011 at 7:29