ZeroK-RTS / Zero-K

Open source RTS game running on the Spring/Recoil engine
https://zero-k.info
GNU General Public License v2.0
690 stars 207 forks source link

Lua NAN in terraform #1496

Closed ashdnazg closed 7 years ago

ashdnazg commented 8 years ago

originally reported here: https://springrts.com/mantis/view.php?id=5334 (replay in mantis report)

[f=0017411] Error: LuaRules::RunCallIn: error = 2, AllowCommand, [Internal Lua error: Call failure] [string "LuaRules/Gadgets/unit_terraform.lua"]:306: bad argument 0000003 to 'SetUnitRulesParam' (number expected, got NAN (check your code for div0))
[f=0017412] Error: LuaRules::RunCallIn: error = 2, GameFrame, [Internal Lua error: Call failure] [string "LuaRules/Gadgets/unit_terraform.lua"]:306: bad argument 0000003 to 'SetUnitRulesParam' (number expected, got NAN (check your code for div0))
stack traceback:
    [C]: in function 'SetUnitRulesParam'
    [string "LuaRules/Gadgets/unit_terraform.lua"]:306: in function 'SetTooltip'
    [string "LuaRules/Gadgets/unit_terraform.lua"]:3054: in function 'GameFrame'
    [string "LuaRules/gadgets.lua"]:1008: in function <[string "LuaRules/gadgets.lua"]:1006>
    (tail call): ?
ashdnazg commented 8 years ago

crash/desync is a minor bug? :D

GoogleFrog commented 8 years ago

I have looked through the code and can't see an obvious way for that number to be NaN. Does Spring immediately crash if NaN is used in arithmetic or does the NaN infect many numbers until it eventually crashes at a callout?

ashdnazg commented 8 years ago

The latter There's something setting the height of the ground in at least one spot to NaN which results in propagation to other parts (min/max map height) and eventually it causes an infinite loop in ray tracing

GoogleFrog commented 8 years ago

Are you saying that, in the engine, the height of a location is being set to NaN?

ashdnazg commented 8 years ago

I'm saying that lua is calling an engine function that sets height with NaN as an argument

GoogleFrog commented 8 years ago

Good, that was what I was asking.

sprunk commented 7 years ago

Duplicate of #2361 (actually the other way around but that one has infologs).