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

An unhandled exception occurred: armor.lua:245: attempt to index a nil value #15

Closed
apoleon opened this issue Dec 17, 2014 · 14 comments
Closed

Comments

@apoleon
Copy link

apoleon commented Dec 17, 2014

Hi,

I have installed the latest version of your mod on my server, 0.4.10, together with shields and wieldview. Unfortunately the whole server crashed at some point with the following error message

ERROR[ServerThread]: Failed to read player inventory
13:51:22: ERROR[main]: ERROR: An unhandled exception occurred: /usr/share/games/minetest/mods/3d_armor/armor.lua:245: attempt to index a nil value
13:51:22: ERROR[main]: stack traceback:
13:51:22: ERROR[main]: >/usr/share/games/minetest/mods/3d_armor/armor.lua:245: in function 'get_armor_formspec'
13:51:22: ERROR[main]: >/usr/share/games/minetest/mods/3d_armor/armor.lua:257: in function 'update_inventory'
13:51:22: ERROR[main]: >/usr/share/games/minetest/mods/3d_armor/armor.lua:402: in function 'func'
13:51:22: ERROR[main]: >/usr/share/games/minetest/builtin/game/misc.lua:17: in function </usr/share/games/minetest/builtin/game/misc.lua:9>
13:51:22: ERROR[main]: >/usr/share/games/minetest/builtin/game/register.lua:348: in function </usr/share/games/minetest/builtin/game/register.lua:336>

@stujones11
Copy link
Owner

Sorry for the late response, I have never come across this error before and have been unable to reproduce it. If you can tell me something specific that will trigger this, I will look into it more.
It might also be helpful to know what other mods you are using in conjuction with this, like skins, inventory etc.

@apoleon
Copy link
Author

apoleon commented Jan 4, 2015

On 04.01.2015 21:25, stujones11 wrote:

Sorry for the late response, I have never come across this error before
and have been unable to reproduce it. If you can tell me something
specific that will trigger this, I will look into it more.
It might also be helpful to know what other mods you are using in
conjuction with this, like skins, inventory etc.

Hi,

I am running a dedicated Debian server, version 0.4.10. The server is
called Yggdrasil [linuxiuvat.de]. I don't know what triggers it exactly
but it happens quite frequently and always crashes the whole server. I
was forced to disable 3d_armor, shields and wieldview because of that.
The following mods are currently installed. I haven't modified any of them.

sprint
spawn
no_guests
munin
craft_guide
areas
sethome
screwdriver
fire
dye
default
signs_lib
plasmascreen
moreores
moreblocks
homedecor_3d_extras
building_blocks
homedecor
mobs
itemframes
inbox
grass
fireworks
fake_fire
computer
chains
carts
xpanes
wool
lrfurn
farming
vessels
tnt
stairs
moss
give_initial_stuff
flowers
doors
creative
bucket
throwing
bones
boats

@stujones11
Copy link
Owner

Ah, so no inventory or skin mod then? That could be a useful clue, I am not sure yet.
I have just pushed some changes that might help me trace the problem and may even prevent the crash. Please let me know the results if you try it.

@apoleon
Copy link
Author

apoleon commented Jan 4, 2015

On 04.01.2015 22:43, stujones11 wrote:

Ah, so no inventory or skin mod then? That could be useful clue, I am
not sure yet.
I have just pushed some changes that might help me trace the problem and
may even prevent the crash. Please let me know the results if you try it.

Thanks. I will try it out tomorrow. I once tried to use the
inventory_plus mod but this one seemed to have another issue, so I
reverted back to the defaults.

@stujones11
Copy link
Owner

No problem, another thing you might want to try is increasing the armor init time, as described in armor.conf.example. Not properly emerged players have often caused this kind of unpredictable wierdness in the past.

@apoleon
Copy link
Author

apoleon commented Jan 5, 2015

I installed the latest version from master and I increased the init time but as soon as the first player joined the server I got this:

07:48:39: ACTION[ServerThread]: vanz leaves game. List of players: salvaje123~
07:48:40: ERROR[ServerThread]: set_player_armor: Failed to read player inventory
07:48:40: ERROR[main]: ERROR: An unhandled exception occurred: ...rver/worlds/yggdrasil/world/worldmods/3d_armor/armor.lua:255: attempt to index a nil value
07:48:40: ERROR[main]: stack traceback:
07:48:40: ERROR[main]: >...rver/worlds/yggdrasil/world/worldmods/3d_armor/armor.lua:255: in function 'get_armor_formspec'
07:48:40: ERROR[main]: >...rver/worlds/yggdrasil/world/worldmods/3d_armor/armor.lua:275: in function 'update_inventory'
07:48:40: ERROR[main]: >...rver/worlds/yggdrasil/world/worldmods/3d_armor/armor.lua:423: in function 'func'
07:48:40: ERROR[main]: >/usr/share/games/minetest/builtin/game/misc.lua:17: in function </usr/share/games/minetest/builtin/game/misc.lua:9>
07:48:40: ERROR[main]: >/usr/share/games/minetest/builtin/game/register.lua:348: in function </usr/share/games/minetest/builtin/game/register.lua:336>
minetest/minetest.log [RO]

@stujones11
Copy link
Owner

This is really weird, I cannot understand why no one else is experiencing this error. This modpack is used on a number of very active servers and I have not had any significant problems reported in quite some time.

I can only guess that there must be something unusual about your setup that is causing it.
At first I thought it must be because most (if not all) other servers are using an inventory mod of some description, however, I have since tested the mod extensively without inventory and found no sign of error.

Is the "default" mod you listed the original one that shipped with minetest_game? It is possible that one from another sub-game might not be compatible in some way or other, grasping at straws...

I have added some more error traps there that are unlikely to get it working for you but may provide me with some more clues if you are willing to give it another go.

@apoleon
Copy link
Author

apoleon commented Jan 7, 2015

On 07.01.2015 22:27, stujones11 wrote:

This is really weird, I cannot understand why no one else is
experiencing this error. This modpack is used on a number of very active
servers and I have not had any significant problems reported in quite
some time.

It seems GunshipPenguin's PvE server was affected as well until he
disabled 3d_armor.

https://forum.minetest.net/viewtopic.php?f=10&t=10616

Unfortunately not everybody does report those issues. I also wonder what
is going on and why a single mod can crash the whole server. I would
normally expect some kind of protection against those unhandled
exceptions by sandboxing each and every mod, so that a failure will
crash the mod but not the server. Well, I guess that's not implemented yet.

I can only guess that there must be something unusual about your setup
that is causing it,
at first I thought it must be because most (if not all) other servers
are using an inventory mod of some description, however, I have since
tested the mod extensively without inventory and found no sign of error.

Is is the "default" mod you listed the original one that shipped with
minetest_game? It is possible that one from another sub-game might not
be compatible in some way or other, grasping at straws...

I have added some more error traps there that are unlikely to get it
working for you but may provide me with some more clues if you are
willing to give it another go.

Ok, I'll give it another try because I really like the mod and the game
would benefit from even more custom armor/clothes and player
appearances. This time I install the inventory_plus mod again. If it
fails again, I'll try debug logging + learning LUA and the minetest API. :)

@stujones11
Copy link
Owner

Sorry, I cannot help it if people don't report problems but I do agree that a server should never crash because of some lua exception. I also agree that modders should do their best to handle exceptions but do we really have to check every single result the api gives us? I generally do as it goes but then maybe I miss something. :)

I am not quite sure exactly what you mean by custom armor but clothing was something I was working on a while back. There is in fact a branch (multiskin) featuring a "clothing" layer. I was working with another modder at the time who promised to create textures, it never happened...

@apoleon
Copy link
Author

apoleon commented Jan 8, 2015

On Wed, 07. Jan 14:37 stujones11 notifications@github.com wrote:

Sorry, I cannot help it if people don't report problems and agree that a
server should never crash because of some lua exception. I also agree that
modders should do their best to handle exceptions but do we really have to
check every single result the api gives us? I generally do as it goes but
then maybe I miss something.

No worries. I was just thinking aloud. Of course the sandbox idea
should be a feature request for the minetest engine.

@apoleon
Copy link
Author

apoleon commented Jan 15, 2015

Hi,

I think the issue is gone. The server hasn't crashed for a week due to this bug. Maybe the upgrade to 0.4.11 was responsible too. I still get error messages like

ERROR[ServerThread]: 3d_armor: Player inventory is nil [set_player_armor]

but they are not fatal. During my testing I've found out that cornernote's inventory_plus mod is severely buggy and often crashes the server. Perhaps you might want to consider to add a note or something to your repository and recommend the fork of Zeg9 instead.

https://github.com/Zeg9/minetest-inventory_plus

@stujones11
Copy link
Owner

Thank you for the update, those messages indicate that the player was not fully emerged at the time armor was initialized. As a result, players may experience some issues like armor inventory not loading, for example.

The only solution (I can think of) right now is to increase the init delay time and/or the number of initialization attempts. It does not really matter how many times you do this, even if it succeeded on the first try.

Re: inventory_plus, I think I already do recommend Zeg9‘s version in the forum topic but I will be sure to add a note in the readme too.

@apoleon
Copy link
Author

apoleon commented Jan 23, 2015

On Fri, 23. Jan 11:37 stujones11 notifications@github.com wrote:

Thank you for the update, those messages indicate that the player was not
fully emerged at it time armor was initialized. As a result, players may
experience some issues like armor inventory not loading, for example.

The only solution (I can think of) right now is to increase the init delay
time and/or the number of initialization attempts. I does not really
matter haw many time you do this, even if it succeeded on the first try.

Re: inventory_plus, I think I do already recommend Zeg9‘s version in the
forum topic but I will be sure to add a note in the readme too.

I have found out that zeg9's version of inventory_plus is also buggy and
crashes the server.

Zeg9/minetest-inventory_plus#2

So unfortunately both are not recommendable at the moment. I installed
the unified_inventory mod today. Let's see how this works.

Being not fully emerged seems to be a regular problem but even when I
increase the init delay time and the number of attempts, there is not
much of a difference. Anyway I haven't had any issues with 3d_armor for
days, so I think this bug report can be closed.

Cheers

@stujones11
Copy link
Owner

I agree, inventory_plus is a bit outdated now and I am pretty sure more folks use unifiied_inventory nowadays, although I can't say I've had a problem with either mod but then I don't run a public server.

Re: emerging players, I have requested a few times for some kind of callback or property that would allow modders to know when it is 'safe' to call certain player object methods, without getting nil index exceptions.
Perhaps that is not as straight forward as it sounds.

Thomas--S pushed a commit to Thomas--S/minetest-3d_armor that referenced this issue Oct 11, 2020
* Added armor:remove_all function
* Corrected README.txt
* Corrected italian translation
* Simplified Italian translation further
* CRUSHFIX: Replaced self.function with self:function

Co-authored-by: Giov4 <brancacciogiovanni1@gmail.com>
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

2 participants