Fix - New game load crashes. Add defensive check. #4216

Merged
the-real-herowl merged 1 commits from fix_hungercrash_newgame into master 2024-03-27 01:22:25 +01:00

Crash info:

2024-03-11 23:42:17: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'mcl_hunger' in callback environment_Step(): ...inetest/games/mineclone2/mods/PLAYER/mcl_hunger/init.lua:269: attempt to index a nil value
2024-03-11 23:42:17: ERROR[Main]: stack traceback:
2024-03-11 23:42:17: ERROR[Main]: 	...inetest/games/mineclone2/mods/PLAYER/mcl_hunger/init.lua:269: in function <...inetest/games/mineclone2/mods/PLAYER/mcl_hunger/init.lua:221>
2024-03-11 23:42:17: ERROR[Main]: 	/usr/share/minetest/builtin/common/register.lua:26: in function </usr/share/minetest/builtin/common/register.lua:12>

When I create a new game on singlenode and load a custom mob, it crashes. I'm assuming this is the case for all new games. We don't check if the player object is set first so I've added a defensive check in.

Could have done with a little more refactoring so it sets the player entry in a local variable we check first, and maybe also create the relevent object if it isn't created on login.

However, it's better than it was.

Testing

Creating new game no longer crashes

Crash info: ``` 2024-03-11 23:42:17: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'mcl_hunger' in callback environment_Step(): ...inetest/games/mineclone2/mods/PLAYER/mcl_hunger/init.lua:269: attempt to index a nil value 2024-03-11 23:42:17: ERROR[Main]: stack traceback: 2024-03-11 23:42:17: ERROR[Main]: ...inetest/games/mineclone2/mods/PLAYER/mcl_hunger/init.lua:269: in function <...inetest/games/mineclone2/mods/PLAYER/mcl_hunger/init.lua:221> 2024-03-11 23:42:17: ERROR[Main]: /usr/share/minetest/builtin/common/register.lua:26: in function </usr/share/minetest/builtin/common/register.lua:12> ``` When I create a new game on singlenode and load a custom mob, it crashes. I'm assuming this is the case for all new games. We don't check if the player object is set first so I've added a defensive check in. Could have done with a little more refactoring so it sets the player entry in a local variable we check first, and maybe also create the relevent object if it isn't created on login. However, it's better than it was. ### Testing Creating new game no longer crashes
ancientmarinerdev added 1 commit 2024-03-12 18:01:08 +01:00
ancientmarinerdev added the
#P1 CRITICAL
label 2024-03-12 18:01:17 +01:00
ancientmarinerdev added this to the 0.87.0 - Prismatic milestone 2024-03-12 18:01:24 +01:00
Member

I wasn't able to reproduce this. I tried creating a new singlenode world with Animalia enabled. This seems like an impossible bug. mcl_hunger.eat_internal[name] get setup in register_on_joinplayer. But the player is in minetest.get_connected_players() before on_joinplayer is called?

I wasn't able to reproduce this. I tried creating a new singlenode world with Animalia enabled. This seems like an impossible bug. mcl_hunger.eat_internal[name] get setup in register_on_joinplayer. But the player is in minetest.get_connected_players() before on_joinplayer is called?
Member

When I create a new game on singlenode and load a custom mob, it crashes. I'm assuming this is the case for all new games. We don't check if the player object is set first so I've added a defensive check in.

What mods were you using when you got this crash?

> When I create a new game on singlenode and load a custom mob, it crashes. I'm assuming this is the case for all new games. We don't check if the player object is set first so I've added a defensive check in. What mods were you using when you got this crash?
Author
Owner

When I create a new game on singlenode and load a custom mob, it crashes. I'm assuming this is the case for all new games. We don't check if the player object is set first so I've added a defensive check in.

What mods were you using when you got this crash?

This was with a custom skyblock mod I'm playing around with. Without this fix, it wouldn't load. It may not happen all the time, but does happen (otherwise I wouldn't be able to generate the stack trace).

> > When I create a new game on singlenode and load a custom mob, it crashes. I'm assuming this is the case for all new games. We don't check if the player object is set first so I've added a defensive check in. > > What mods were you using when you got this crash? > This was with a custom skyblock mod I'm playing around with. Without this fix, it wouldn't load. It may not happen all the time, but does happen (otherwise I wouldn't be able to generate the stack trace).
Member

This was with a custom skyblock mod I'm playing around with. Without this fix, it wouldn't load. It may not happen all the time, but does happen (otherwise I wouldn't be able to generate the stack trace).

Understood. I won't be able to use your setup to try to reproduce unless you make that custom skyblock mod available. No worries and no pressure to make it available in a larval state. I'll just keep working on either the bone meal API update or the minecarts update.

> This was with a custom skyblock mod I'm playing around with. Without this fix, it wouldn't load. It may not happen all the time, but does happen (otherwise I wouldn't be able to generate the stack trace). Understood. I won't be able to use your setup to try to reproduce unless you make that custom skyblock mod available. No worries and no pressure to make it available in a larval state. I'll just keep working on either the bone meal API update or the minecarts update.
Author
Owner

This was with a custom skyblock mod I'm playing around with. Without this fix, it wouldn't load. It may not happen all the time, but does happen (otherwise I wouldn't be able to generate the stack trace).

Understood. I won't be able to use your setup to try to reproduce unless you make that custom skyblock mod available. No worries and no pressure to make it available in a larval state. I'll just keep working on either the bone meal API update or the minecarts update.

Once I'm satisfied with it, or gone as far as I'm willing to go for now, I will release it. I'm just kind of unblocking it and solving issues for now.

With this and the biomes fix, it probably will be releasable.

> > This was with a custom skyblock mod I'm playing around with. Without this fix, it wouldn't load. It may not happen all the time, but does happen (otherwise I wouldn't be able to generate the stack trace). > > Understood. I won't be able to use your setup to try to reproduce unless you make that custom skyblock mod available. No worries and no pressure to make it available in a larval state. I'll just keep working on either the bone meal API update or the minecarts update. Once I'm satisfied with it, or gone as far as I'm willing to go for now, I will release it. I'm just kind of unblocking it and solving issues for now. With this and the biomes fix, it probably will be releasable.
the-real-herowl approved these changes 2024-03-27 01:15:20 +01:00
the-real-herowl left a comment
Owner

LGTM

LGTM
the-real-herowl merged commit 0b521ef92b into master 2024-03-27 01:22:25 +01:00
the-real-herowl deleted branch fix_hungercrash_newgame 2024-03-27 01:22:27 +01:00
Sign in to join this conversation.
No reviewers
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#4216
No description provided.