minetest-mods / digtron

A modular tunnel boring/construction machine mod for Minetest.
https://forum.minetest.net/viewtopic.php?f=9&t=16295
Other
22 stars 29 forks source link

Another crash #16

Open gpcf opened 6 years ago

gpcf commented 6 years ago

The server crashes repeatedly with the following traceback:

2017-12-04 12:14:22: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod '' in callback node_on_receive_fields(): /var/games/minetest-server/.minetest/mods/digtron/util.lua:175: bad argument #1 to 'pairs' (table expected, got nil)
2017-12-04 12:14:22: ERROR[Main]: stack traceback:
2017-12-04 12:14:22: ERROR[Main]:       [C]: in function 'pairs'
2017-12-04 12:14:22: ERROR[Main]:       /var/games/minetest-server/.minetest/mods/digtron/util.lua:175: in function 'burn'
2017-12-04 12:14:22: ERROR[Main]:       ...est-server/.minetest/mods/digtron/util_execute_cycle.lua:234: in function 'execute_dig_cycle'
2017-12-04 12:14:22: ERROR[Main]:       ...server/.minetest/mods/digtron/nodes/node_controllers.lua:144: in function 'auto_cycle'
2017-12-04 12:14:22: ERROR[Main]:       ...server/.minetest/mods/digtron/nodes/node_controllers.lua:255: in function <...server/.minetest/mods/digtron/nodes/node_controllers.lua:229>
gpcf commented 6 years ago

It seems that this happen because the inventories of the storage and fuel modules disappear somehow.

FaceDeer commented 6 years ago

Did this happen with a Digtron left running away from you, toward unloaded regions? This and the most recent crash report both remind me of the old issue #5, which involved a mysterious problem in which the Digtron's position and its metadata's position got out of synch with each other.

numberZero commented 5 years ago

Test case is necessary, something like core stress-test.

gpcf commented 5 years ago

I can confirm this still happens. Our theory is that server lag can destroy the digtron fuel inventories and thus cause this bug. Also, it has been observed that it does not seem to happen with delay=2 set in the control panel.

2018-10-28 15:51:48: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod '' in callback node_on_receive_fields(): /var/games/minetest-server/.minetest/mods/digtron/util.lua:175: bad argument #1 to 'pairs' (table expected, got nil)
2018-10-28 15:51:48: ERROR[Main]: stack traceback:
2018-10-28 15:51:48: ERROR[Main]:       [C]: in function 'pairs'
2018-10-28 15:51:48: ERROR[Main]:       /var/games/minetest-server/.minetest/mods/digtron/util.lua:175: in function 'burn'
2018-10-28 15:51:48: ERROR[Main]:       ...est-server/.minetest/mods/digtron/util_execute_cycle.lua:242: in function 'execute_dig_cycle'
2018-10-28 15:51:48: ERROR[Main]:       ...server/.minetest/mods/digtron/nodes/node_controllers.lua:146: in function 'auto_cycle'
2018-10-28 15:51:48: ERROR[Main]:       ...server/.minetest/mods/digtron/nodes/node_controllers.lua:260: in function <...server/.minetest/mods/digtron/nodes/node_controllers.lua:234>
2018-10-28 15:51:52: ERROR[Main]: The following mods could not be found: "digilines_inventory" "digilines_lcd" "digilines_lightsensor" "digilines_rtc" "fire" "mesecons_compatibility" "mob_bear" "mob_warthog" "xban"
FaceDeer commented 5 years ago

Also, it has been observed that it does not seem to happen with delay=2 set in the control panel.

This is starting to fit really well into my own theory, in that case. :) Over the Christmas break I did a ton of work on the "dfcaverns" mod and I spent a while struggling with a crash where I was getting nil values where tables should have been - there was literally no conceivable way that the variable should be nil, but it was anyway. It turned out that it was almost certainly because the section of code where it was happening had an embarrassingly large number of table allocations being done, and when I cleaned that up the crash stopped happening.

Setting the delay to 2 means your Digtron is allocating half as many tables-per-second, so perhaps the Lua engine is able to keep up at that speed. As I commented in one of the other issues filed on this matter, I'm doing some code cleanup in the optimization branch that might help. The "pointset" class in particular was a bad offender, it used a ton of nested tables and now it just uses one.

I'll keep cleaning, there's probably still plenty of places I can squeeze out more tables. Digtron was my first mod, back in the day, it's got plenty of cruft.

numberZero commented 5 years ago

Are there any warnings like 2019-01-03 23:20:47: WARNING[Server]: Map::getNodeMetadata(): Block not found? These should happen when it digs faster than blocks are generated.

numberZero commented 5 years ago

Report upstream, with all the relevant information, like MT version, Lua version, build flags, etc.

FaceDeer commented 5 years ago

Reported. I'll see how that report goes, and probably close down some of these Digtron issues as dupes.

Also, I'll do some more optimization work on Digtron's memory allocation when I've got some more spare time. I've already done some, hopefully that'll reduce the incidences of crashes if this theory is correct.