MidLevel / Ruffles

Lightweight and fully managed reliable UDP library.
MIT License
212 stars 28 forks source link

Deadlock in ReliableSequencedChannel.HandleAck(ArraySegment<byte> payload) #40

Open THplusplus opened 1 year ago

THplusplus commented 1 year ago

Describe the bug Endless loop due to wrong data type in counter variable i.

To Reproduce I don't have enough understanding of the inner workings to tell how exactly to reproduce this. However it's obvious that the for loop in ReliableSequencedChannel.HandleAck(ArraySegment<byte> payload) can never complete when bits is greater than 255. Not sure IF bits should ever be greater than 255, but it is in my case. The debugger shows a value of 4128 in my case. Same issue may probably occur in ReliableChannel as well.

Expected behavior It shouldn't lock up. Either the counter i should be of type int or it should be guaranteed that bits can never exceed 255.

Environment (please complete the following information):

Additional context The deadlock occurs after a few minutes during loadtests of my game server. It is possible that the game server is sending or receiving too much data which may increase the chance of this issue ocurring.