Skip to content

Uncaught exception crash in PlayerRegistry.GetPlayer #11

@roydejong

Description

@roydejong

PlayerRegistry.GetPlayer can cause a crash if a player key is missing from the dictionary.

In this case it seemed to happen in a disconnect race condition:

Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'ziuMSceapEuNN7wRGQXrZg' was not present in the dictionary.
   at System.Collections.Concurrent.ConcurrentDictionary`2.ThrowKeyNotFoundException(TKey key)
   at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
   at BeatTogether.DedicatedServer.Kernel.PlayerRegistry.GetPlayer(String userId) in E:\Projects\BeatTogether.DedicatedServer\BeatTogether.DedicatedServer.Kernel\PlayerRegistry.cs:line 40
   at BeatTogether.DedicatedServer.Kernel.DedicatedInstance.OnDisconnect(EndPoint endPoint, DisconnectReason reason) in E:\Projects\BeatTogether.DedicatedServer\BeatTogether.DedicatedServer.Kernel\DedicatedInstance.cs:line 406
   at BeatTogether.LiteNetLib.LiteNetServer.HandleDisconnect(EndPoint endPoint, DisconnectReason reason)
   at BeatTogether.LiteNetLib.Handlers.DisconnectPacketHandler.Handle(EndPoint endPoint, DisconnectHeader packet, SpanBufferReader& reader)
   at BeatTogether.LiteNetLib.LiteNetServer.HandlePacket(EndPoint endPoint, ReadOnlySpan`1 buffer)
   at BeatTogether.LiteNetLib.LiteNetServer.ReceivePacket(EndPoint endPoint, ReadOnlySpan`1 buffer)
   at BeatTogether.LiteNetLib.LiteNetServer.OnReceived(EndPoint endPoint, ReadOnlySpan`1 buffer)
   at NetCoreServer.UdpServer.ProcessReceiveFrom(SocketAsyncEventArgs e)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pNativeOverlapped)

[process exited with code 3762504530]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions