MoreMesecons/moremesecons_entity_detector/init.lua:68: bad argument #2 to 'set_string' (string expected, got table) #7743

Closed
opened 2024-11-28 15:17:04 +01:00 by AliasAlreadyTaken · 12 comments

2024-11-28 14:15:59: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'mesecons' in callback environment_Step(): .../mods/MoreMesecons/moremesecons_entity_detector/init.lua:68: bad argument #2 to 'set_string' (string expected, got table)
2024-11-28 14:15:59: ERROR[Main]: stack traceback:
2024-11-28 14:15:59: ERROR[Main]: [C]: in function 'set_string'
2024-11-28 14:15:59: ERROR[Main]: .../mods/MoreMesecons/moremesecons_entity_detector/init.lua:68: in function 'action'
2024-11-28 14:15:59: ERROR[Main]: .../5.10.0/Yourland_main/bin/../mods/digilines/internal.lua:106: in function 'transmit'
2024-11-28 14:15:59: ERROR[Main]: ...e/mt/5.10.0/Yourland_main/bin/../mods/digilines/init.lua:60: in function 'receptor_send'
2024-11-28 14:15:59: ERROR[Main]: ....10.0/Yourland_main/bin/../mods/digistuff/ioexpander.lua:68: in function 'ioexp_digiline_send'
2024-11-28 14:15:59: ERROR[Main]: ....10.0/Yourland_main/bin/../mods/digistuff/ioexpander.lua:103: in function 'action_change'
2024-11-28 14:15:59: ERROR[Main]: ...Yourland_main/bin/../mods/mesecons/mesecons/internal.lua:230: in function <...Yourland_main/bin/../mods/mesecons/mesecons/internal.lua:223>
2024-11-28 14:15:59: ERROR[Main]: ...rland_main/bin/../mods/mesecons/mesecons/actionqueue.lua:131: in function 'old_execute'
2024-11-28 14:15:59: ERROR[Main]: .../bin/../mods/mesecons_debug/overrides/mesecons_queue.lua:27: in function 'execute'
2024-11-28 14:15:59: ERROR[Main]: ...rland_main/bin/../mods/mesecons/mesecons/actionqueue.lua:121: in function 'func'
2024-11-28 14:15:59: ERROR[Main]: ...ourland_main/bin/../builtin/profiler/instrumentation.lua:124: in function <...ourland_main/bin/../builtin/profiler/instrumentation.lua:117>
2024-11-28 14:15:59: ERROR[Main]: .../5.10.0/Yourland_main/bin/../builtin/common/register.lua:26: in function <.../5.10.0/Yourland_main/bin/../builtin/common/register.lua:12>

2024-11-28 14:15:59: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'mesecons' in callback environment_Step(): .../mods/MoreMesecons/moremesecons_entity_detector/init.lua:68: bad argument #2 to 'set_string' (string expected, got table) 2024-11-28 14:15:59: ERROR[Main]: stack traceback: 2024-11-28 14:15:59: ERROR[Main]: [C]: in function 'set_string' 2024-11-28 14:15:59: ERROR[Main]: .../mods/MoreMesecons/moremesecons_entity_detector/init.lua:68: in function 'action' 2024-11-28 14:15:59: ERROR[Main]: .../5.10.0/Yourland_main/bin/../mods/digilines/internal.lua:106: in function 'transmit' 2024-11-28 14:15:59: ERROR[Main]: ...e/mt/5.10.0/Yourland_main/bin/../mods/digilines/init.lua:60: in function 'receptor_send' 2024-11-28 14:15:59: ERROR[Main]: ....10.0/Yourland_main/bin/../mods/digistuff/ioexpander.lua:68: in function 'ioexp_digiline_send' 2024-11-28 14:15:59: ERROR[Main]: ....10.0/Yourland_main/bin/../mods/digistuff/ioexpander.lua:103: in function 'action_change' 2024-11-28 14:15:59: ERROR[Main]: ...Yourland_main/bin/../mods/mesecons/mesecons/internal.lua:230: in function <...Yourland_main/bin/../mods/mesecons/mesecons/internal.lua:223> 2024-11-28 14:15:59: ERROR[Main]: ...rland_main/bin/../mods/mesecons/mesecons/actionqueue.lua:131: in function 'old_execute' 2024-11-28 14:15:59: ERROR[Main]: .../bin/../mods/mesecons_debug/overrides/mesecons_queue.lua:27: in function 'execute' 2024-11-28 14:15:59: ERROR[Main]: ...rland_main/bin/../mods/mesecons/mesecons/actionqueue.lua:121: in function 'func' 2024-11-28 14:15:59: ERROR[Main]: ...ourland_main/bin/../builtin/profiler/instrumentation.lua:124: in function <...ourland_main/bin/../builtin/profiler/instrumentation.lua:117> 2024-11-28 14:15:59: ERROR[Main]: .../5.10.0/Yourland_main/bin/../builtin/common/register.lua:26: in function <.../5.10.0/Yourland_main/bin/../builtin/common/register.lua:12>
Author
Owner
                action = function (pos, node, channel, msg)
                        local meta = minetest.get_meta(pos)
                        local active_channel = meta:get_string("digiline_channel")
                        if channel ~= active_channel then
                                return
                        end
                        if (type(msg) ~= "string") then
                                core.log("error","#7743 pos=".. dump(pos))
                                core.log("error","#7743 node=".. dump(node))
                                core.log("error","#7743 channel=".. dump(channel))
                                core.log("error","#7743 msg=".. dump(msg))
                        end
                        meta:set_string("scanname", msg)
                        if meta:get_string("formspec") ~= "" then
                                make_formspec(meta)
                        end
                end,

``` action = function (pos, node, channel, msg) local meta = minetest.get_meta(pos) local active_channel = meta:get_string("digiline_channel") if channel ~= active_channel then return end if (type(msg) ~= "string") then core.log("error","#7743 pos=".. dump(pos)) core.log("error","#7743 node=".. dump(node)) core.log("error","#7743 channel=".. dump(channel)) core.log("error","#7743 msg=".. dump(msg)) end meta:set_string("scanname", msg) if meta:get_string("formspec") ~= "" then make_formspec(meta) end end, ```
AliasAlreadyTaken added the
1. kind/bug
2. prio/critical
labels 2024-11-28 15:22:55 +01:00
Author
Owner

This is the results:

2024-11-28 15:05:24: ERROR[Server]: #7743 pos={
	z = -3,
	x = -381,
	y = 13
}
2024-11-28 15:05:24: ERROR[Server]: #7743 node={
	param1 = 14,
	name = "moremesecons_entity_detector:entity_detector_on",
	param2 = 0
}
2024-11-28 15:05:24: ERROR[Server]: #7743 channel=""
2024-11-28 15:05:24: ERROR[Server]: #7743 msg={
	d = false,
	c = false,
	b = false,
	a = true
}
This is the results: ``` 2024-11-28 15:05:24: ERROR[Server]: #7743 pos={ z = -3, x = -381, y = 13 } 2024-11-28 15:05:24: ERROR[Server]: #7743 node={ param1 = 14, name = "moremesecons_entity_detector:entity_detector_on", param2 = 0 } 2024-11-28 15:05:24: ERROR[Server]: #7743 channel="" 2024-11-28 15:05:24: ERROR[Server]: #7743 msg={ d = false, c = false, b = false, a = true } ```
AliasAlreadyTaken added the
3. source/mod upstream
label 2024-11-28 16:16:38 +01:00

I was able to trigger it on the test server by sneaking and placing a digilines I/O expander against an entity detector, near my snake farm.

I was able to trigger it on the test server by sneaking and placing a digilines I/O expander against an entity detector, near my snake farm.
Member

Using same modset, I have no issue on 5.8.0 and crash on 5.10.0 and 5.9.1.
I also tried disabling mesecons_debug - same crash.

The difference is in handling of incorrect arguments in case of meta:set_tring("key", {}) - it silently unsets the key on 5.8 and errors on 5.9+

diff --git a/moremesecons_entity_detector/init.lua b/moremesecons_entity_detector/init.lua
index 165e399..77421f6 100644
--- a/moremesecons_entity_detector/init.lua
+++ b/moremesecons_entity_detector/init.lua
@@ -65,7 +65,13 @@ local object_detector_digiline = {
                        if channel ~= active_channel then
                                return
                        end
-                       meta:set_string("scanname", msg)
+                        if type(msg) == "string" then
+                            -- this errors on 5.9+ if msg is not string
+                            meta:set_string("scanname", msg)
+                        else
+                            -- preserve 5.8.0 behavior
+                            meta:set_string("scanname", "")
+                        end
                        if meta:get_string("formspec") ~= "" then
                                make_formspec(meta)
                        end
-- 
Using same modset, I have no issue on 5.8.0 and crash on 5.10.0 and 5.9.1. I also tried disabling `mesecons_debug` - same crash. The difference is in handling of incorrect arguments in case of `meta:set_tring("key", {})` - it silently unsets the key on 5.8 and errors on 5.9+ ```diff diff --git a/moremesecons_entity_detector/init.lua b/moremesecons_entity_detector/init.lua index 165e399..77421f6 100644 --- a/moremesecons_entity_detector/init.lua +++ b/moremesecons_entity_detector/init.lua @@ -65,7 +65,13 @@ local object_detector_digiline = { if channel ~= active_channel then return end - meta:set_string("scanname", msg) + if type(msg) == "string" then + -- this errors on 5.9+ if msg is not string + meta:set_string("scanname", msg) + else + -- preserve 5.8.0 behavior + meta:set_string("scanname", "") + end if meta:get_string("formspec") ~= "" then make_formspec(meta) end -- ```
AliasAlreadyTaken added this to the 1.1.126.2 milestone 2024-11-29 18:18:26 +01:00
Author
Owner

Upstream issue moremesecons:

Repro:

Have mesecons, digilines, moremesecons

  1. Place mesecons_luacontroller:luacontroller
  2. Place moremesecons_entity_detector:entity_detector
  3. Add channel "kaputt" to entity_detector
  4. Add code to luacontroller: digiline_send("kaputt",{})
  5. Press Execute

Crash

AsyncErr: Lua: Runtime error from mod 'mesecons' in callback environment_Step(): .../mods/moremesecons/moremesecons_entity_detector/init.lua:68: bad argument #2 to 'set_string' (string expected, got table)
stack traceback:
	[C]: in function 'set_string'
	.../mods/moremesecons/moremesecons_entity_detector/init.lua:68: in function 'action'
	.../5.10.0/minetest-temp/bin/../mods/digilines/internal.lua:106: in function 'transmit'
	...test/5.10.0/minetest-temp/bin/../mods/digilines/init.lua:60: in function 'receptor_send'
	...emp/bin/../mods/mesecons/mesecons_luacontroller/init.lua:752: in function <...emp/bin/../mods/mesecons/mesecons_luacontroller/init.lua:746>
	...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:131: in function 'execute'
	...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:121: in function <...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:76>
	.../5.10.0/minetest-temp/bin/../builtin/common/register.lua:26: in function <.../5.10.0/minetest-temp/bin/../builtin/common/register.lua:12>

This doesn't happen in 5.8.0, only in 5.9.1 and 5.10.0 and 5.11.0-dev

The difference is in handling of incorrect arguments in case of meta:set_string("key", {}) - it silently unsets the key on 5.8 and errors on 5.9+

Please add a type check

Upstream issue moremesecons: Repro: > Have mesecons, digilines, moremesecons 1. Place mesecons_luacontroller:luacontroller 2. Place moremesecons_entity_detector:entity_detector 3. Add channel `"kaputt"` to entity_detector 4. Add code to luacontroller: `digiline_send("kaputt",{})` 5. Press Execute > Crash ``` AsyncErr: Lua: Runtime error from mod 'mesecons' in callback environment_Step(): .../mods/moremesecons/moremesecons_entity_detector/init.lua:68: bad argument #2 to 'set_string' (string expected, got table) stack traceback: [C]: in function 'set_string' .../mods/moremesecons/moremesecons_entity_detector/init.lua:68: in function 'action' .../5.10.0/minetest-temp/bin/../mods/digilines/internal.lua:106: in function 'transmit' ...test/5.10.0/minetest-temp/bin/../mods/digilines/init.lua:60: in function 'receptor_send' ...emp/bin/../mods/mesecons/mesecons_luacontroller/init.lua:752: in function <...emp/bin/../mods/mesecons/mesecons_luacontroller/init.lua:746> ...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:131: in function 'execute' ...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:121: in function <...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:76> .../5.10.0/minetest-temp/bin/../builtin/common/register.lua:26: in function <.../5.10.0/minetest-temp/bin/../builtin/common/register.lua:12> ``` This doesn't happen in 5.8.0, only in 5.9.1 and 5.10.0 and 5.11.0-dev The difference is in handling of incorrect arguments in case of `meta:set_string("key", {})` - it silently unsets the key on 5.8 and errors on 5.9+ Please add a type check
Author
Owner
Upstream issue https://github.com/minetest-mods/MoreMesecons/issues/38
Member

also affected:

  • moremesecons player detector (digiline_send("kaputt",{scanname = {}}))
  • mesecons player detector (digiline_send("kaputt",{}))
also affected: - moremesecons player detector (`digiline_send("kaputt",{scanname = {}})`) - mesecons player detector (`digiline_send("kaputt",{})`)
Author
Owner

Upstream issue mesecons:

Repro:

Have mesecons, digilines

  1. Place mesecons_luacontroller:luacontroller
  2. Place mesecons_detector:object_detector
  3. Add channel "kaputt" to object_detector
  4. Add code to luacontroller: digiline_send("kaputt",{})
  5. Press Execute

Crash

AsyncErr: Lua: Runtime error from mod 'mesecons' in callback environment_Step(): ...est-temp/bin/../mods/mesecons/mesecons_detector/init.lua:70: bad argument #2 to 'set_string' (string expected, got table)
stack traceback:
	[C]: in function 'set_string'
	...est-temp/bin/../mods/mesecons/mesecons_detector/init.lua:70: in function 'action'
	.../5.10.0/minetest-temp/bin/../mods/digilines/internal.lua:106: in function 'transmit'
	...test/5.10.0/minetest-temp/bin/../mods/digilines/init.lua:60: in function 'receptor_send'
	...emp/bin/../mods/mesecons/mesecons_luacontroller/init.lua:752: in function <...emp/bin/../mods/mesecons/mesecons_luacontroller/init.lua:746>
	...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:131: in function 'execute'
	...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:121: in function <...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:76>
	.../5.10.0/minetest-temp/bin/../builtin/common/register.lua:26: in function <.../5.10.0/minetest-temp/bin/../builtin/common/register.lua:12>

This doesn't happen in 5.8.0, only in 5.9.1 and 5.10.0 and 5.11.0-dev

The difference is in handling of incorrect arguments in case of meta:set_string("key", {}) - it silently unsets the key on 5.8 and errors on 5.9+

Please add a type check

Upstream issue mesecons: Repro: > Have mesecons, digilines 1. Place mesecons_luacontroller:luacontroller 2. Place mesecons_detector:object_detector 3. Add channel `"kaputt"` to object_detector 4. Add code to luacontroller: `digiline_send("kaputt",{})` 5. Press Execute > Crash ``` AsyncErr: Lua: Runtime error from mod 'mesecons' in callback environment_Step(): ...est-temp/bin/../mods/mesecons/mesecons_detector/init.lua:70: bad argument #2 to 'set_string' (string expected, got table) stack traceback: [C]: in function 'set_string' ...est-temp/bin/../mods/mesecons/mesecons_detector/init.lua:70: in function 'action' .../5.10.0/minetest-temp/bin/../mods/digilines/internal.lua:106: in function 'transmit' ...test/5.10.0/minetest-temp/bin/../mods/digilines/init.lua:60: in function 'receptor_send' ...emp/bin/../mods/mesecons/mesecons_luacontroller/init.lua:752: in function <...emp/bin/../mods/mesecons/mesecons_luacontroller/init.lua:746> ...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:131: in function 'execute' ...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:121: in function <...etest-temp/bin/../mods/mesecons/mesecons/actionqueue.lua:76> .../5.10.0/minetest-temp/bin/../builtin/common/register.lua:26: in function <.../5.10.0/minetest-temp/bin/../builtin/common/register.lua:12> ``` This doesn't happen in 5.8.0, only in 5.9.1 and 5.10.0 and 5.11.0-dev The difference is in handling of incorrect arguments in case of `meta:set_string("key", {})` - it silently unsets the key on 5.8 and errors on 5.9+ Please add a type check
Author
Owner
Upstream issue: https://github.com/minetest-mods/mesecons/issues/691
AliasAlreadyTaken added the
4. step/ready to QA test
label 2024-11-29 20:39:41 +01:00
AliasAlreadyTaken added the
4. step/QA OK
label 2024-11-30 00:52:13 +01:00
Member
https://github.com/minetest-mods/MoreMesecons/pull/39
Member

MoreMesecons pr merged, mesecons also pushed a fix :-)

MoreMesecons pr merged, mesecons also pushed a fix :-)

I think this could be closed

I think this could be closed
AliasAlreadyTaken added the
5. result/fixed
label 2025-03-08 17:27:12 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/bugtracker#7743
No description provided.