Closed jhcole closed 8 years ago
The metatable of cold_perl_values is changed, maybe the garbage collector deleted cold_perl_values[y] when minetest.get_perlin took memory. Actually it should know that cold_perl_values[y][x] is accessed there and avoid deleting it, shouldn't it?
I thought it might be related to garbage collection, but I would have hoped Lua would know better. Its very confusing to me at the moment what happened.
It happened again :(
2016-08-14 13:34:58: ERROR[Main]: ServerError: Runtime error from mod 'snow' in callback environment_Step(): /home/foz/.minetest/mods/snow/src/falling_snow.lua:109: attempt to index a nil value 2016-08-14 13:34:58: ERROR[Main]: stack traceback: 2016-08-14 13:34:58: ERROR[Main]: /home/foz/.minetest/mods/snow/src/falling_snow.lua:109: in function 'cold_perlin_test' 2016-08-14 13:34:58: ERROR[Main]: /home/foz/.minetest/mods/snow/src/falling_snow.lua:137: in function 'get_snow' 2016-08-14 13:34:58: ERROR[Main]: /home/foz/.minetest/mods/snow/src/falling_snow.lua:226: in function 'step_func' 2016-08-14 13:34:58: ERROR[Main]: /home/foz/.minetest/mods/snow/src/falling_snow.lua:274: in function </home/foz/.minetest/mods/snow/src/falling_snow.lua:273> 2016-08-14 13:34:58: ERROR[Main]: /usr/local/share/minetest/builtin/game/register.lua:369: in function </usr/local/share/minetest/builtin/game/register.lua:349>
Maybe minetest.get_perlin takes lots of memory. l now assume the garbage collector does not know that it is used there. Anyway, if it removes cold_perl_values[y], it needs memory, so it should not cache v if it happened: https://github.com/Splizard/minetest-mod-snow/commit/30b0dd9557aa72ca787d108424e90e8969df0641
Strangely your error message is attempt to index a nil value
, i.e. x or y is nil (somehow?) but if the field was nil, e.g. due to garbage collection, the error message would be different: attempt to index field '?' (a nil value)
.
If it still crashes, it now tells at least if y (or both) (L109) or only x (L110) becomes nil, please inform me.
try adding
if x == nil then
error("nil x")
end
if y == nil then
error("ni y")
end
and seeing if that causes it to crash due to either of them being nil
rubenwardy, as long as this can't be reproduced, the code doesn't help much
x and y is passed to l_get2d, which copies the values to NoisePerlin2D l assume
but this crashes as soon as a the first player joins the server.
2016-08-20 06:23:59: ERROR[Main]: ServerError: Runtime error from mod 'snow' in callback environment_Step(): .../foz/Code/minetest/bin/../mods/snow/src/falling_snow.lua:122: x no integer but 38.588001251221 y no integer but -43.385997772217 2016-08-20 06:23:59: ERROR[Main]: stack traceback: 2016-08-20 06:23:59: ERROR[Main]: [C]: in function 'error' 2016-08-20 06:23:59: ERROR[Main]: .../foz/Code/minetest/bin/../mods/snow/src/falling_snow.lua:122: in function 'cold_perlin_test' 2016-08-20 06:23:59: ERROR[Main]: .../foz/Code/minetest/bin/../mods/snow/src/falling_snow.lua:155: in function 'get_snow' 2016-08-20 06:23:59: ERROR[Main]: .../foz/Code/minetest/bin/../mods/snow/src/falling_snow.lua:244: in function 'step_func' 2016-08-20 06:23:59: ERROR[Main]: .../foz/Code/minetest/bin/../mods/snow/src/falling_snow.lua:292: in function <.../foz/Code/minetest/bin/../mods/snow/src/falling_snow.lua:291> 2016-08-20 06:23:59: ERROR[Main]: /home/foz/Code/minetest/bin/../builtin/game/register.lua:369: in function
l think l forgot to round the player position, so the cache didn't work and l assume because float numbers are inaccurate in lua, the indices change slightly.
I deployed the latest (b1a7d12) a week ago and haven't seen it happen again so hopefully it is fixed. I have, however, run out of memory twice in the last week #22
Running 90e08fe. I can't figure out how line falling_snow.lua:98 is fine but then it chokes on 109. I've only seen this error once.