SwissalpS / replacer

tool that replaces nodes by clicking on them and another that inspects nodes and entities (Mod for Luanti/Minetest)
GNU Lesser General Public License v3.0
4 stars 3 forks source link

`hud_add()` can fail and return a nil, resulting in crash on next `hud_get()` call #52

Closed yl-whosit closed 7 months ago

yl-whosit commented 7 months ago

According to the API:

hud_add(hud definition): add a HUD element described by HUD def, returns ID number on success

(our internal ref 6502)

SwissalpS commented 7 months ago

(our internal ref 6502)

Where can I see that? So you have cases where hud_add actually fails?

yl-whosit commented 7 months ago

Had a couple of crashes like this:

ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod '' in callback item_OnPlace(): ../mods/rhotator/notify.lua:120: bad argument #1 to 'hud_get' (number expected, got nil)
ERROR[Main]: stack traceback:
ERROR[Main]: [C]: in function 'hud_get'
ERROR[Main]: ../mods/rhotator/notify.lua:120: in function 'notify'
ERROR[Main]: ../mods/rhotator/init.lua:690: in function 'copy_rotation_callback'
ERROR[Main]: ../mods/rhotator/init.lua:485: in function 'func'
ERROR[Main]: ../builtin/profiler/instrumentation.lua:108: in function 'callback'
ERROR[Main]: ../builtin/game/item.lua:285: in function 'on_place'
ERROR[Main]: ../mods/replacer/replacer.lua:214: in function 'replace_single_node'
ERROR[Main]: ../mods/replacer/replacer.lua:307: in function <../mods/replacer/replacer.lua:252>

As I understand it, some other bugged mod can be creating too many huds and not removing them...

(our internal ref 6502)

Where can I see that?

https://gitea.your-land.de/your-land/bugtracker/issues/6502

yl-whosit commented 7 months ago

Since replacer crashed twice and we didn't have other mods crashing like this, I'm starting to suspect it may be the replacer code somehow, but I don't see it...

SwissalpS commented 7 months ago

Thanks, I'll look into it. Can't hurt to include code that doesn't crash even in a very unlikely event.

SwissalpS commented 7 months ago

If you do figure out how to replicate it, I'd be grateful to be notified, for testing reasons.

yl-whosit commented 7 months ago

Wait, did I mix up rhotator and replacer?

SwissalpS commented 7 months ago

Now I'm confused. [replacer] has no HUD! I was thinking of [postool]

yl-whosit commented 7 months ago

Ok, so both crashes are from rhotator... and I was looking at the right code, I just filed it to a wrong repo... Sorry. :/ (trying to fix bugs without enough sleep is unproductive...)

SwissalpS commented 7 months ago

it's OK. Made me check [postool] and found that it doesn't check against nil everywhere.