BinarySerializer icon indicating copy to clipboard operation
BinarySerializer copied to clipboard

Thead-safety

Open ricebus opened this issue 5 years ago • 8 comments

Hi,

So I've been using the serializer with threads & hi-speed packets and after a while there seems to be corruption (the serializer spits out mal-formed packets). The issue was resolved after I locked the serialize() function call. Also, I'm using the same serializer object for all calls.

So, my question is, is the serializer thread-safe? is there any common practice you suggest in scenarios like this?

George.

ricebus avatar Aug 13 '19 09:08 ricebus

It should be but it’s possible there’s a bug. Actually, now that I think about it I wonder if there’s a thread safety issue in the bit handling. I didn’t even think about that. Are you using bit fields?

jefffhaynes avatar Aug 13 '19 11:08 jefffhaynes

Nope.

ricebus avatar Aug 13 '19 12:08 ricebus

I can send you my code + Wireshark recording if that helps... Again this happens only in serialization and not deserialization

ricebus avatar Aug 14 '19 11:08 ricebus

That would be great. I’ll get to it as soon as possible

jefffhaynes avatar Aug 14 '19 11:08 jefffhaynes

Is there a private way to send you info? Can I have your email?

ricebus avatar Aug 14 '19 11:08 ricebus

Can you setup a private repo and give me access? They're free now.

jefffhaynes avatar Aug 18 '19 17:08 jefffhaynes

I haven't been able to reproduce this so if you can post some code I'd like to take a look. Thanks

jefffhaynes avatar Aug 24 '19 14:08 jefffhaynes

Look at NcpSharp.Server, SendPacket (you can look for the lock statement, without it everything crashes)

ricebus avatar Aug 31 '19 20:08 ricebus