minetest_game icon indicating copy to clipboard operation
minetest_game copied to clipboard

craftguide crash: attempt to get length of field 'recipes' (a nil value)

Open ghost opened this issue 3 years ago • 4 comments

minetest core version 5.4 & 5.5-dev (server/multiplayer) MTG update at commit 0a90bd8a0ec530f48e1bd9a438e24bd85cc9cd66

Server crash: 2021-04-01 17:42:40: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'sfinv' in callback on_playerReceiveFields(): .../bin/../games/minetest_game/mods/mtg_craftguide/init.lua:372: attempt to get length of field 'recipes' (a nil value) 2021-04-01 17:42:40: ERROR[Main]: stack traceback: 2021-04-01 17:42:40: ERROR[Main]: .../bin/../games/minetest_game/mods/mtg_craftguide/init.lua:372: in function 'on_receive_fields' 2021-04-01 17:42:40: ERROR[Main]: .../bin/../games/minetest_game/mods/mtg_craftguide/init.lua:430: in function <.../bin/../games/minetest_game/mods/mtg_craftguide/init.lua:429> 2021-04-01 17:42:40: ERROR[Main]: /home/minetest/minetest/bin/../builtin/game/register.lua:425: in function </home/minetest/minetest/bin/../builtin/game/register.lua:409>

ghost avatar Apr 01 '21 17:04 ghost

https://github.com/minetest/minetest_game/blob/0a90bd8a0ec530f48e1bd9a438e24bd85cc9cd66/mods/mtg_craftguide/init.lua#L370-L378

How to reproduce?

SmallJoker avatar Apr 01 '21 17:04 SmallJoker

idk

ghost avatar Apr 01 '21 23:04 ghost

It looks like someone created a craft recipe without the recipe. Perhaps "recipe” was spelled wrong?

minetest.register_craft({
  output = “foo”,
  repice = {“bar”, “baz”},
})

Edit: Actally, I didn’t look closely at the code @SmallJoker posted. I think I am way off.

AntumDeluge avatar Jun 14 '21 03:06 AntumDeluge

https://github.com/minetest/minetest_game/blob/0a90bd8a0ec530f48e1bd9a438e24bd85cc9cd66/mods/mtg_craftguide/init.lua#L370-L378

Should probably be a sanity check anywhere data.recipies is used to ensure that it is not nil before using it.

elseif (data.recipes ~= nil)  and (fields.recipe_next or fields.recipe_prev) then
  data.rnum = data.rnum + (fields.recipe_next and 1 or -1)
  if data.rnum > #data.recipes then
    data.rnum = 1
  elseif data.rnum == 0 then
    data.rnum = #data.recipes
  end
  return true 

neoh4x0r avatar Jul 02 '21 19:07 neoh4x0r