minetest-mods / digilines

Digilines is a mod for minetest which adds data bus wires
Other
40 stars 37 forks source link

Disallow LCD messages that aren't strings or numbers #89

Closed cheapie closed 1 month ago

cheapie commented 2 months ago

This fixes a crash (that seems to only happen in 5.9?) that occurs if a table is sent to an LCD.

SmallJoker commented 2 months ago

Do you happen to have an error backtrace? Whereas this fix surely works, I am not sure whether that's the best way to fix such issue.

cheapie commented 1 month ago

The exact backtrace varies slightly depending on where the message came from, but with a minimal reproduction (Luacontroller connected to LCD, LCD on channel "lcd", Luacontroller programmed with digiline_send("lcd",{}) as the only line):

2024-09-06 07:35:20: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'mesecons' in callback environment_Step(): /home/cheapie/.minetest/mods/digilines/lcd.lua:262: bad argument #2 to 'set_string' (string expected, got table)
2024-09-06 07:35:20: ERROR[Main]: stack traceback:
2024-09-06 07:35:20: ERROR[Main]:   [C]: in function 'set_string'
2024-09-06 07:35:20: ERROR[Main]:   /home/cheapie/.minetest/mods/digilines/lcd.lua:262: in function 'action'
2024-09-06 07:35:20: ERROR[Main]:   /home/cheapie/.minetest/mods/digilines/internal.lua:106: in function 'transmit'
2024-09-06 07:35:20: ERROR[Main]:   /home/cheapie/.minetest/mods/digilines/init.lua:60: in function 'receptor_send'
2024-09-06 07:35:20: ERROR[Main]:   .../.minetest/mods/mesecons/mesecons_luacontroller/init.lua:752: in function <.../.minetest/mods/mesecons/mesecons_luacontroller/init.lua:746>
2024-09-06 07:35:20: ERROR[Main]:   ...cheapie/.minetest/mods/mesecons/mesecons/actionqueue.lua:131: in function 'execute'
2024-09-06 07:35:20: ERROR[Main]:   ...cheapie/.minetest/mods/mesecons/mesecons/actionqueue.lua:121: in function 'func'
2024-09-06 07:35:20: ERROR[Main]:   ...ocal/share/minetest/builtin/profiler/instrumentation.lua:124: in function <...ocal/share/minetest/builtin/profiler/instrumentation.lua:117>
2024-09-06 07:35:20: ERROR[Main]:   /usr/local/share/minetest/builtin/common/register.lua:26: in function </usr/local/share/minetest/builtin/common/register.lua:12>

For the original crash I observed on a server elsewhere (this one mentions digistuff because the message came from there):

2024-09-01 18:37:26: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod '' in callback node_on_receive_fields(): /home/medic/worlds/creative/worldmods/digilines/lcd.lua:262: bad argument #2 to 'set_string' (string expected, got table)
2024-09-01 18:37:26: ERROR[Main]: stack traceback:
2024-09-01 18:37:26: ERROR[Main]:   [C]: in function 'set_string'
2024-09-01 18:37:26: ERROR[Main]:   /home/medic/worlds/creative/worldmods/digilines/lcd.lua:262: in function 'action'
2024-09-01 18:37:26: ERROR[Main]:   ...e/medic/worlds/creative/worldmods/digilines/internal.lua:106: in function 'transmit'
2024-09-01 18:37:26: ERROR[Main]:   /home/medic/worlds/creative/worldmods/digilines/init.lua:60: in function 'receptor_send'
2024-09-01 18:37:26: ERROR[Main]:   ...edic/worlds/creative/worldmods/digistuff/touchscreen.lua:81: in function <...edic/worlds/creative/worldmods/digistuff/touchscreen.lua:60>
SmallJoker commented 1 month ago

I see. Yes, that makes sense to me. Thank you for explaining.

Will merge in a few days unless there are objections.