digtron icon indicating copy to clipboard operation
digtron copied to clipboard

Seems the inventory table is not retrieved

Open neko259 opened this issue 5 years ago • 6 comments

I've got a crash on the latest 2 commits: digtron/util.lua:193: bad argument #1 to 'pairs' Not sure what is the cause.

neko259 avatar Jan 13 '19 15:01 neko259

A lot of people aren't sure about the cause, including me. :( It seems that minetest api calls that should be returning tables are instead returning "nil", seemingly at random. I've been working under the assumption that this is being caused by low memory conditions; see issue #8067.

I am increasingly at a loss as to what I can do in mod code to compensate for this. Perfectly innocuous function calls are failing here, all over the place. Hopefully in this case the crash didn't cause the Digtron's nodes to become corrupted? As in, when you restarted the server and tried running the Digtron again, it didn't crash again? I added some asserts last night to try guarding against bad data being written to the world's database, that's worse than simply crashing and resuming.

FaceDeer avatar Jan 13 '19 18:01 FaceDeer

I've just added a guard against this specific instance of an "impossible" nil table. It'll cause the Digtron to temporarily think it doesn't have fuel, which might interrupt its cycling and require the player to set it moving again but at least won't crash or corrupt anything.

I'm playing whack-a-mole here, Digtron is a big mod with lots of other API calls where this might crop up.

FaceDeer avatar Jan 13 '19 18:01 FaceDeer

I have some additional info around this. After some update the fuel nodes in all my digtrons became broken. If I click on it it shows the formspec with no inventory at all. Removing and placing the node fixed the crash.

neko259 avatar Jan 13 '19 18:01 neko259

Same symptoms I've been getting reports of for a year now, then, and none of my efforts to guard against it or prevent it are working. If you're using the version of Digtron I submitted last night it should have crashed before it even attempted to write a fuel node that was missing its inventory data. So maybe it's the actual write-to-world step that's failing after all, and not the read-from-world step as I'd been speculating.

This is incredibly frustrating. I'm going to spend some time writing test mods to see if I can reproduce any aspect of these problems.

FaceDeer avatar Jan 13 '19 19:01 FaceDeer

Yes. I have finally been able to reproduce this bug locally, or at least one of the symptoms of the various reports I've been seeing. I'm able to get Digtrons to "lose" parts of themselves. I think I may have figured out what particular aspect of my code this is breaking in, too - it's something to do with how Digtrons detect if they're adjacent to unloaded nodes. I think I may be able to fix this in-mod after all.

FaceDeer avatar Jan 13 '19 22:01 FaceDeer

adjacent to unloaded blocks.

Hey, that’s not supposed to work at all. Inventories can’t be created in non-existent blocks. The problem is that MT doesn’t report that properly (it does warn, in some cases at least). See an explanation in minetest/minetest#8067.

numberZero avatar Jan 14 '19 18:01 numberZero