This object is in archive! 

ArithmeticException: Function does not accept floating point Not-a-Number values

Guest shared this bug 20 months ago
Solved

Game version: 1.202.066 Automatons

SE crashed while running a local world with heavy shooting between a station full of gatling turrets and a mid-sized large block ship with custom rotor+hinge based PDCs. The ship is using Turret Control Blocks, the station does not. The crash indicates that somehow a NaN was produced in the calculations. Please double check the possible code paths, you should be able to find it.


2023-04-14 00:54:00.142 - Thread:   1 ->  Exception occurred: System.ArithmeticException: Function does not accept floating point Not-a-Number values.
   at System.Math.Sign(Single value)
   at SpaceEngineers.Game.Entities.Blocks.MyTurretControlBlock.SetRotorAngleAndVelocity(MyMotorStator rotor, Single targetAngle, Single speedMultiplier, Single& angleDifference, Boolean& canAim, Single precisionInRadians)
   at SpaceEngineers.Game.Entities.Blocks.MyTurretControlBlock.RotationAndElevation(Boolean& canAimAzimuth, Boolean& canAimElevation)
   at SpaceEngineers.Game.Entities.Blocks.MyTurretControlBlock.UpdateAiWeapon()
   at SpaceEngineers.Game.Entities.Blocks.MyTurretControlBlock.UpdateAfterSimulation()
   at Sandbox.Game.Entities.MyParallelEntityUpdateOrchestrator.UpdateAfterSimulation()
   at Sandbox.Game.Entities.MyParallelEntityUpdateOrchestrator.DispatchAfterSimulation()
   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()
   at Sandbox.MySandboxGame.Run(Boolean customRenderLoop, Action disposeSplashScreen)
   at SpaceEngineers.MyProgram.Main(String[] args)

Replies (5)

photo
1

The station was inside a Safe Zone and could not be damaged. The ship got a lot of damage. If that matters.

This was either caused by a race condition on destroying part of a rotor+hinge based PDC or an edge case in your angle math.

photo
1

Reproduced this issue once more with the same safe zones + heavy grids test world. So it is at least somewhat reproducible. I'm going to try to make it reproducible more frequently with a test world.

photo
1

I'm unable to reproduce this issue with the same world and ship. I tried it a lot of times, but no crash. So this must be some kind of corner case which happens rarely. It may be narrowed down by code review.

photo
1

Found the root cause of the problem in the MyTurretControlBlock.LookAt method by code review.

Please find the root cause analysis and a C# test project to reproduce the issue on GitHub:

https://github.com/viktor-ferenczi/LookAtNanRepro

This test case reproduces the arithmetic issue outside the game, making it easier to debug and fix it.

photo
1

Hello, Viktor!

Thank you for writing to us.

We are already aware of this issue and it will be fixed in the upcoming hotfixes.

We are closing this thread as "Solved" for now.

Kind Regards,

Keen Software House: QA Department

Replies have been locked on this page!