Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Crash when digtron and mesecons_piston interact (minetest-5.8.0, latest mod versions) #668

Open
dennisjenkins75 opened this issue Mar 25, 2024 · 0 comments

Comments

@dennisjenkins75
Copy link

dennisjenkins75 commented Mar 25, 2024

I am not 100% certain on the repro. A user on my server managed to make it crash while operating a digtron. I suspect that they either dug a piston, or placed one. Below is the stack trace from the server logs, along with excerpts from the mods at the relevant lines of code. It is possible that the bug is in digtron, but after looking at the code, I'm thinking that mesecons_pistons could be more defensive when handling the pos parameter in its piston_orientation() callback.

1hit@EdgyNet:~$ ./opt/minetest/bin/minetestserver --version
Minetest 5.8.0 (Linux)
Using LuaJIT 2.1.0-beta3
BUILD_TYPE=Release
RUN_IN_PLACE=0
USE_CURL=1
STATIC_SHAREDIR="/home/1hit/opt/minetest/share/minetest"

1hit@EdgyNet:~$ (cd ./worlds/world/worldmods/digtron; git rev-parse HEAD)
0c8f652b2c9029615a937434a3de5a78d8d5172d

1hit@EdgyNet:~$ (cd ./worlds/world/worldmods/mesecons; git rev-parse HEAD)
cffbc33e6dfcf01f62d890b7e71b4fb46cfc8063

1hit@EdgyNet:~$ ./bin/crash-report.py < ./logs/2024-03-25.txt
ServerError: AsyncErr: Lua: Runtime error from mod 'digtron' in callback node_on_receive_fields(): ...orlds/world/worldmods/mesecons/mesecons_pistons/init.lua:133: attempt to index a nil value
stack traceback:
        ...orlds/world/worldmods/mesecons/mesecons_pistons/init.lua:133: in function 'after_place_node'
        .../worlds/world/worldmods/digtron/util_item_place_node.lua:155: in function 'item_place_node'
        ...t/worlds/world/worldmods/digtron/nodes/node_builders.lua:404: in function 'execute_build'
        ...it/worlds/world/worldmods/digtron/util_execute_cycle.lua:345: in function 'execute_dig_cycle'
        ...orlds/world/worldmods/digtron/nodes/node_controllers.lua:166: in function 'auto_cycle'
        ...orlds/world/worldmods/digtron/nodes/node_controllers.lua:283: in function <...orlds/world/worldmods/digtron/nodes/node_controllers.lua:257>

mesecons_pistons/init.lua:125-142 Line 133 is node.param2 = orientations[node.param2][1]

local function piston_orientate(pos, placer)
        mesecon.mvps_set_owner(pos, placer)
        if not placer then
                return
        end
        local pitch = math.deg(placer:get_look_vertical())
        local node = minetest.get_node(pos)
        if pitch > 55 then
                node.param2 = orientations[node.param2][1]
        elseif pitch < -55 then
                node.param2 = orientations[node.param2][2]
        else
                return
        end
        minetest.swap_node(pos, node)
        -- minetest.after, because on_placenode for unoriented piston must be p$
        minetest.after(0, mesecon.on_placenode, pos, node)
end

digtron/util_item_place_node.lua:150-159 Line 155 is the inner if statement.

        -- Run callback, using genuine player for per-node definition.
        if def.after_place_node then
                -- Deepcopy place_to and pointed_thing because callback can mod$
                local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
                local pointed_thing_copy = copy_pointed_thing(pointed_thing)
                if def.after_place_node(place_to_copy, placer, itemstack,
                                pointed_thing_copy) then
                        take_item = false
                end
        end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant