FabioZumbi12 / SEDiscordBridge

A Torch plugin to connect the SE server to Discord
MIT License
13 stars 11 forks source link

[BUG] Trying to mention Player that cannot be found on discord causes Freeze #29

Closed LordTylus closed 5 years ago

LordTylus commented 5 years ago

Hello

I used the following chatmessage today on our server: @Legocam I cannot find anything in the logs showing your ship being hacked.

First time I did that my Server UI froze and nothing happened. to it anymore. Then I tried the same thing ingame:

Which froze the server and caused the frozen Thread detection to kick in. @ Annotated user does not exist on our Discord.

15:09:34.8475 [ERROR]  Torch: Frozen thread dump Main thread
Common prefix:
   at System.Threading.ManualResetEventSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.SpinThenBlockingWait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.InternalWait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at SEDiscordBridge.DiscordBridge.MentionNameToID(String msg, DiscordChannel chann)
   at SEDiscordBridge.DiscordBridge.SendChatMessage(String user, String msg)
   at SEDiscordBridge.SEDiscordBridgePlugin.MessageRecieved(TorchChatMessage msg, Boolean& consumed)
   at Torch.API.Managers.MessageRecievedDel.Invoke(TorchChatMessage msg, Boolean& consumed)
   at Torch.Managers.ChatManager.ChatManagerClient.RaiseMessageRecieved(TorchChatMessage msg) in C:\jenkins\workspace\Torch_Torch_master\Torch\Managers\ChatManager\ChatManagerClient.cs:line 155
   at Torch.Managers.ChatManager.ChatManagerClient.Multiplayer_ChatMessageReceived(UInt64 steamUserId, String messageText, ChatChannel channel, Int64 targetId, String customAuthorName) in C:\jenkins\workspace\Torch_Torch_master\Torch\Managers\ChatManager\ChatManagerClient.cs:line 138
   at Sandbox.Engine.Multiplayer.MyMultiplayerBase.RaiseChatMessageReceived(UInt64 steamUserID, String messageText, ChatChannel channel, Int64 targetId, String customAuthorName)
   at Sandbox.Engine.Multiplayer.MyDedicatedServer.OnChatMessage(ChatMsg& msg)
   at OnChatMessageRecieved_Server_0(ChatMsg )
   at lambda_method(Closure , IMyEventOwner , ChatMsg , DBNull , DBNull , DBNull , DBNull , DBNull )
   at VRage.Network.CallSite`7.Invoke(BitStream stream, Object obj, Boolean validate)
   at VRage.Network.MyReplicationLayer.Invoke(CallSite callSite, BitStream stream, Object obj, EndpointId source, MyClientStateBase clientState, Boolean validate)
   at VRage.Network.MyReplicationServer.OnEvent(MyPacketDataBitStreamBase data, CallSite site, Object obj, IMyNetObject sendAs, Nullable`1 position, EndpointId source)
   at VRage.Network.MyReplicationLayer.OnEvent(MyPacketDataBitStreamBase data, NetworkId networkId, NetworkId blockedNetId, UInt32 eventId, EndpointId sender, Nullable`1 position)
   at VRage.Network.MyReplicationLayer.ProcessEvent(MyPacketDataBitStreamBase data, EndpointId sender)
   at VRage.Network.MyReplicationLayer.OnEvent(MyPacket packet)
   at Sandbox.Engine.Multiplayer.MyTransportLayer.ProcessMessage(MyPacket p)
   at Sandbox.Engine.Multiplayer.MyTransportLayer.HandleMessage(MyPacket p)
   at Sandbox.Engine.Networking.MyReceiveQueue.Process(NetworkMessageDelegate handler)
   at Sandbox.Engine.Networking.MyNetworkReader.Process()
   at Sandbox.MySandboxGame.Update()
   at Sandbox.Engine.Platform.Game.UpdateInternal()
   at RunSingleFrame_0(Object )
   at Sandbox.Engine.Platform.FixedLoop.<>c__DisplayClass11_0.<Run>b__0()
   at Sandbox.Engine.Platform.GenericLoop.Run(VoidAction tickCallback)
   at Sandbox.Engine.Platform.Game.RunLoop()
   at Sandbox.MySandboxGame.Run(Boolean customRenderLoop, Action disposeSplashScreen)
   at Torch.VRageGame.DoStart() in C:\jenkins\workspace\Torch_Torch_master\Torch\VRageGame.cs:line 244
   at Torch.VRageGame.Run() in C:\jenkins\workspace\Torch_Torch_master\Torch\VRageGame.cs:line 119
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Suffix 0
   at System.Threading.Monitor.ObjWait(Boolean exitContext, Int32 millisecondsTimeout, Object obj)

Suffix 1
   at System.Threading.Monitor.ObjWait(Boolean exitContext, Int32 millisecondsTimeout, Object obj)

Suffix 2
   at System.Threading.Monitor.ObjWait(Boolean exitContext, Int32 millisecondsTimeout, Object obj)

15:09:34.8475 [FATAL]  Initializer: System.TimeoutException: Server watchdog detected that the server was frozen for at least 60 seconds.
   at Torch.Server.TorchServer.CheckServerResponding(Object state) in C:\jenkins\workspace\Torch_Torch_master\Torch.Server\TorchServer.cs:line 237
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()
System.TimeoutException: Server watchdog detected that the server was frozen for at least 60 seconds.
   at Torch.Server.TorchServer.CheckServerResponding(Object state) in C:\jenkins\workspace\Torch_Torch_master\Torch.Server\TorchServer.cs:line 237
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()
LordTylus commented 5 years ago

Cause of the problem was discovered

Solution not quite yet...

When writing @ ingame it works When using @ from console it doesnt.

The source code executed is exactly the same. Only difference is that the ingame message is processed by a worker thread called Main Thread. And the Message from the console is executed on the real main thread / ui thread which deadlocks itself when calling the MemberListAsync from Discord.

FabioZumbi12 commented 5 years ago

@Bishbash777 any idea?

LordTylus commented 5 years ago

@FabioZumbi12 we looked at it together,

we disabled that server can mention people which seems to work fine.

FabioZumbi12 commented 5 years ago

https://github.com/FabioZumbi12/SEDiscordBridge/commit/7e77e2890d707ea7148a3fb05199a1a1cb857fcd should fix the issue without remove mention from console.

LordTylus commented 5 years ago

I will test it tomorrow I guess and then close the Issue,.

I see you merged the commits of @Bishbash777 as well.

LordTylus commented 5 years ago

Ahh I see its not yet updated on torch Plugin page, when can we expect a new version there?

Bishbash777 commented 5 years ago

@FabioZumbi12 Mark this as solved