Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unusual error and crash. #20

Closed
jhcole opened this issue Aug 10, 2016 · 8 comments
Closed

Unusual error and crash. #20

jhcole opened this issue Aug 10, 2016 · 8 comments

Comments

@jhcole
Copy link

jhcole commented Aug 10, 2016

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.

2016-08-10 04:17:41: 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-10 04:17:41: ERROR[Main]: stack traceback:
2016-08-10 04:17:41: ERROR[Main]: /home/foz/.minetest/mods/snow/src/falling_snow.lua:109: in function 'cold_perlin_test'
2016-08-10 04:17:41: ERROR[Main]: /home/foz/.minetest/mods/snow/src/falling_snow.lua:137: in function 'get_snow'
2016-08-10 04:17:41: ERROR[Main]: /home/foz/.minetest/mods/snow/src/falling_snow.lua:226: in function 'step_func'
2016-08-10 04:17:41: 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-10 04:17:41: ERROR[Main]: /usr/local/share/minetest/builtin/game/register.lua:369: in function </usr/local/share/minetest/builtin/game/register.lua:349>

@HybridDog
Copy link
Collaborator

HybridDog commented Aug 11, 2016

-- cache perlin noise tests

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?

@jhcole
Copy link
Author

jhcole commented Aug 11, 2016

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.

@jhcole
Copy link
Author

jhcole commented Aug 16, 2016

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>

@HybridDog
Copy link
Collaborator

HybridDog commented Aug 16, 2016

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: 30b0dd9

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.

@HybridDog HybridDog reopened this Aug 16, 2016
@rubenwardy
Copy link

rubenwardy commented Aug 19, 2016

try adding

if x == nil then
    error("nil x")
end
if y == nil then
    error("ni y")
end

to

and seeing if that causes it to crash due to either of them being nil

HybridDog added a commit that referenced this issue Aug 19, 2016
M  src/falling_snow.lua
@HybridDog
Copy link
Collaborator

HybridDog commented Aug 19, 2016

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

fozolo pushed a commit to FozLand/snow that referenced this issue Aug 20, 2016
M  src/falling_snow.lua
fozolo pushed a commit to FozLand/snow that referenced this issue Aug 20, 2016
@HybridDog
Copy link
Collaborator

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.

HybridDog added a commit that referenced this issue Aug 21, 2016
@jhcole
Copy link
Author

jhcole commented Sep 2, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants