[1.105.024] [DS] - Crash KeyNotFoundException Detatching Mechanical Connection

LordTylus shared this bug 12 months ago
Outdated

Hello there,

we have had 2 crashes on our server so far with a Stacktrace that looks like this:

23:31:30.4602 [FATAL]  Initializer: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.SortedDictionary`2.get_Item(TKey key)
   at Sandbox.Engine.Physics.MyGridPhysicalHierarchy.BreakLink(Int64 linkId, MyCubeGrid parentNode, MyCubeGrid childNode)
   at Sandbox.Game.Entities.Blocks.MyMechanicalConnectionBlockBase.BreakLinks(MyCubeGrid topGrid, MyAttachableTopBlockBase topBlock)
   at Sandbox.Game.Entities.Blocks.MyMechanicalConnectionBlockBase.Detach(MyCubeGrid topGrid, Boolean updateGroups)
   at System.Action`1.Invoke(T obj)
   at System.DelegateExtensions.InvokeIfNotNull[T1](Action`1 handler, T1 arg1)
   at VRage.Game.Entity.MyEntity.Delete()
   at Sandbox.Game.Entities.MyEntities.DeleteRememberedEntities()
   at Sandbox.Game.Entities.MyEntities.UpdateAfterSimulation()
   at Sandbox.Game.World.MySector.UpdateAfterSimulation()
   at Sandbox.Game.World.MySession.UpdateComponents()
   at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime)
   at Sandbox.MySandboxGame.Update()
Unfortunately I have no idea how it happened. I am assuming some kind of Threading issue maybe. As according to the stacktrace the Server was deleting an NPC ship or something like that.

No idea how to reproduce this. So I thought I let you know, as Torch servers sadly dont report Crashes to your Analytics server.

Comments (3)

photo
1

Hello, Engineer!


Thank you for your feedback! Your topic has been added between considered issues.

Please keep voting for the issue as it will help us to identify the most serious bugs.


We really appreciate your patience.


Kind Regards

Keen Software House: QA Department

photo
1

This line is fishy in the override method `MyGridPhysicalHierarchy.BreakLink`:

childNode = this.GetNode(parentNode).m_children[linkId].NodeData;
In addition to the one reported by LordTylus I have seen another problem on this same line when this.GetNode(parentNode) returns null. They may be related or different symptoms of the same underlying root cause.

It seems to happen if run on server side. Haven't seen it in single player (client only) yet. It seems to point in the direction of a race condition in deleting connected subgrids.

It happens very often (25% or higher probability) on cutting (Ctrl-X) a mechanical group, e.g. multiple grids connected by mechanical connections. It happens both in creative and survival (for admin players with creative tools enabled).

I can stop on the above line in a debugger when the problem happens, but due to the optimized runtime I cannot really inspect variables. Not enough to know what's going on. Only Keen can debug it efficiently while running a debug build.

Exception:

17:06:32.8645 [FATAL]  Initializer: System.NullReferenceException: Object reference not set to an instance of an object.
   at Sandbox.Engine.Physics.MyGridPhysicalHierarchy.BreakLink(Int64 linkId, MyCubeGrid parentNode, MyCubeGrid childNode)
   at Sandbox.Game.Entities.Blocks.MyMechanicalConnectionBlockBase.BreakLinks(MyCubeGrid topGrid, MyAttachableTopBlockBase topBlock)
   at Sandbox.Game.Entities.Blocks.MyMechanicalConnectionBlockBase.Detach(MyCubeGrid topGrid, Boolean updateGroups)
   at System.DelegateExtensions.InvokeIfNotNull[T1](Action`1 handler, T1 arg1)
   at VRage.Game.Entity.MyEntity.Delete()
   at VRage.Game.Components.MyHierarchyComponentBase.Delete()
   at VRage.Game.Entity.MyEntity.Delete()
   at Sandbox.Game.Entities.MyEntities.DeleteRememberedEntities()
   at Sandbox.Game.Entities.MyEntities.UpdateAfterSimulation()
   at Sandbox.Game.World.MySector.UpdateAfterSimulation()
   at Sandbox.Game.World.MySession.UpdateComponents()
   at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime)
   at Sandbox.MySandboxGame.Update()
   at Sandbox.Engine.Platform.Game.UpdateInternal()
   at Sandbox.Engine.Platform.Game.RunSingleFrame()
   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()
...

photo
1

Handling of the childNode == null case seems to be bugged in the Dedicated Server. Please put a breakpoint there, then try to cut out groups of mechanically connected subgrids until you run into that case. Use a combination of cutting one subgrid (Ctrl-Shift-X), then cutting the rest of it (Ctrl-X) on at least 3 connected subgrids. It gave me a 100% reproduction rate.