tnt/init.lua:204: bad argument #1 to 'pairs' (table expected, got nil) #3744

Closed
opened 2023-02-06 02:01:13 +00:00 by AliasAlreadyTaken · 10 comments

It probably happened when someone used an electrumese sword and the shot hit ... a shot!

2023-02-06 01:55:08: ACTION[Server]: TNT owned by DragonWrangler1 detonated at (3243,-4238,-748) with radius 1
2023-02-06 01:55:08: ACTION[Server]: LuaEntitySAO "yl_nether:sword_bullet" at (3244,-4237,-748) (id=10174, hp=0) punched LuaEntitySAO "yl_nether:sword_bullet" at (3244,-4237,-748) (id=10174, hp=0), damage=10

Resulting Crash:

2023-02-06 01:56:05: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'yl_nether' in callback luaentity_Step(): /home/mt/5.6.1/Minetest_live/bin/../mods/tnt/init.lua:204: bad argument #1 to 'pairs' (table expected, got nil)
2023-02-06 01:56:05: ERROR[Main]: stack traceback:
2023-02-06 01:56:05: ERROR[Main]: 	[C]: in function 'pairs'
2023-02-06 01:56:05: ERROR[Main]: 	/home/mt/5.6.1/Minetest_live/bin/../mods/tnt/init.lua:204: in function 'entity_physics'
2023-02-06 01:56:05: ERROR[Main]: 	/home/mt/5.6.1/Minetest_live/bin/../mods/tnt/init.lua:453: in function 'boom'
2023-02-06 01:56:05: ERROR[Main]: 	...e/mt/5.6.1/Minetest_live/bin/../mods/yl_nether/tools.lua:54: in function 'func'
2023-02-06 01:56:05: ERROR[Main]: 	...inetest_live/bin/../builtin/profiler/instrumentation.lua:107: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:100>

Dumbfix:

if entity_drops then
	for _, item in pairs(entity_drops) do
		add_drop(drops, item)
	end
end
It probably happened when someone used an electrumese sword and the shot hit ... a shot! ``` 2023-02-06 01:55:08: ACTION[Server]: TNT owned by DragonWrangler1 detonated at (3243,-4238,-748) with radius 1 2023-02-06 01:55:08: ACTION[Server]: LuaEntitySAO "yl_nether:sword_bullet" at (3244,-4237,-748) (id=10174, hp=0) punched LuaEntitySAO "yl_nether:sword_bullet" at (3244,-4237,-748) (id=10174, hp=0), damage=10 ``` Resulting Crash: ``` 2023-02-06 01:56:05: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'yl_nether' in callback luaentity_Step(): /home/mt/5.6.1/Minetest_live/bin/../mods/tnt/init.lua:204: bad argument #1 to 'pairs' (table expected, got nil) 2023-02-06 01:56:05: ERROR[Main]: stack traceback: 2023-02-06 01:56:05: ERROR[Main]: [C]: in function 'pairs' 2023-02-06 01:56:05: ERROR[Main]: /home/mt/5.6.1/Minetest_live/bin/../mods/tnt/init.lua:204: in function 'entity_physics' 2023-02-06 01:56:05: ERROR[Main]: /home/mt/5.6.1/Minetest_live/bin/../mods/tnt/init.lua:453: in function 'boom' 2023-02-06 01:56:05: ERROR[Main]: ...e/mt/5.6.1/Minetest_live/bin/../mods/yl_nether/tools.lua:54: in function 'func' 2023-02-06 01:56:05: ERROR[Main]: ...inetest_live/bin/../builtin/profiler/instrumentation.lua:107: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:100> ``` Dumbfix: ``` if entity_drops then for _, item in pairs(entity_drops) do add_drop(drops, item) end end ```
AliasAlreadyTaken added the
1. kind/bug
2. prio/critical
labels 2023-02-06 02:01:28 +00:00
Member

dumbfix looks like proper fix, implemented that: 496150ac4c

dumbfix looks like proper fix, implemented that: https://gitea.your-land.de/your-land/tnt/commit/496150ac4c6c5bc1d9bdcb9d1f9c769d526507ea
Member

i'm curious which mob is returning nil when it's supposed to return an empty table, but there's no harm done w/ this check.

i'm curious which mob is returning `nil` when it's supposed to return an empty table, but there's no harm done w/ this check.
Author
Owner

I edited the report when I found what was detonated. Seems like a yl_nether:sword_bullet was hit by a yl_nether:sword_bullet?

I edited the report when I found what was detonated. Seems like a yl_nether:sword_bullet was hit by a yl_nether:sword_bullet?
Member

I edited the report when I found what was detonated. Seems like a yl_nether:sword_bullet was hit by a yl_nether:sword_bullet?

  1. that's ... incredibly unlikely, unless 2 players were shooting swords at each other..., i wish we could see the entity IDs to tell whether the shot hit itself or another shot.
  2. that happened almost a minute before the crash, probably wasn't related?
> I edited the report when I found what was detonated. Seems like a yl_nether:sword_bullet was hit by a yl_nether:sword_bullet? 1. that's ... incredibly unlikely, unless 2 players were shooting swords at each other..., i wish we could see the entity IDs to tell whether the shot hit itself or another shot. 2. that happened almost a minute before the crash, probably wasn't related?
Author
Owner
  1. That's something we could test.

  2. It sometimes takes a while until the server prints the error message and its the last related action recorded

1. That's something we could test. 2. It sometimes takes a while until the server prints the error message and its the last related action recorded
AliasAlreadyTaken added the
4. step/ready to QA test
label 2023-02-06 06:11:52 +00:00
AliasAlreadyTaken added this to the 1.1.117.1 milestone 2023-02-06 06:11:59 +00:00
Member
"yl_nether:sword_bullet" has no `on_blast` callback
minetest.register_entity("yl_nether:sword_bullet", {
    physical = true,
    visual = "sprite",
    visual_size = {x = 1, y = 1},
    textures = {"yl_nether_electrum_orb.png"},
    collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
    _lifetime = 9, -- seconds before removing
    _timer = 0, -- initial value
    _owner = "unknown", -- initial value
    _trigger_sd = 0,
    static_save = false,

    -- when the entity gets punched
    on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
        local full_punch_interval = tool_capabilities.full_punch_interval or 1

        -- only on full punch
        if time_from_last_punch < full_punch_interval then
            return
        end

        local v = math.random(1, 8)
        local velocity = dir

        velocity.x = velocity.x * v
        velocity.y = velocity.y * v
        velocity.z = velocity.z * v
        self.object:setvelocity(velocity)
    end,

    on_step = function(self, dtime, moveresult)
        self._timer = self._timer + dtime
        local pos = self.object:getpos()
        if self._timer > self._lifetime or not yl_nether.inside_world_bounds(pos, 0) then
            self.object:remove()
            yl_nether.fired_table[self._owner] = nil
            return
        end

        local collided = false
        for _, collision in ipairs(moveresult.collisions) do
            collided = true
            if collision.type == "node" then
                local collision_pos = collision.node_pos

                if yl_nether.has.tnt and not minetest.find_node_near(collision_pos, 1, {"group:water"}) then
                    tnt.boom(collision_pos, {
                        radius = 1,
                        damage_radius = 4,
                        owner = self._owner,
                    })
                end

            elseif collision.type == "object" then
                local obj = collision.object
                if minetest.is_player(obj) then
                    -- punch player
                    local puncher = minetest.get_player_by_name(self._owner)

                    if puncher then
                        obj:punch(puncher, 1.0, {
                            full_punch_interval = 1.0,
                            damage_groups = {fleshy = 8},
                        })
                    end
                    -- punch entity
                else
                    local puncher = minetest.get_player_by_name(self._owner)

                    if puncher then
                        obj:punch(puncher, 1.0, {
                            full_punch_interval = 1.0,
                            damage_groups = {fleshy = 8},
                        })
                    end
                end
            end
        end

        if collided then
            self.object:remove()
            yl_nether.fired_table[self._owner] = nil
        end
    end
})
<details><summary>"yl_nether:sword_bullet" has no `on_blast` callback</summary> ```lua minetest.register_entity("yl_nether:sword_bullet", { physical = true, visual = "sprite", visual_size = {x = 1, y = 1}, textures = {"yl_nether_electrum_orb.png"}, collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}, _lifetime = 9, -- seconds before removing _timer = 0, -- initial value _owner = "unknown", -- initial value _trigger_sd = 0, static_save = false, -- when the entity gets punched on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir) local full_punch_interval = tool_capabilities.full_punch_interval or 1 -- only on full punch if time_from_last_punch < full_punch_interval then return end local v = math.random(1, 8) local velocity = dir velocity.x = velocity.x * v velocity.y = velocity.y * v velocity.z = velocity.z * v self.object:setvelocity(velocity) end, on_step = function(self, dtime, moveresult) self._timer = self._timer + dtime local pos = self.object:getpos() if self._timer > self._lifetime or not yl_nether.inside_world_bounds(pos, 0) then self.object:remove() yl_nether.fired_table[self._owner] = nil return end local collided = false for _, collision in ipairs(moveresult.collisions) do collided = true if collision.type == "node" then local collision_pos = collision.node_pos if yl_nether.has.tnt and not minetest.find_node_near(collision_pos, 1, {"group:water"}) then tnt.boom(collision_pos, { radius = 1, damage_radius = 4, owner = self._owner, }) end elseif collision.type == "object" then local obj = collision.object if minetest.is_player(obj) then -- punch player local puncher = minetest.get_player_by_name(self._owner) if puncher then obj:punch(puncher, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 8}, }) end -- punch entity else local puncher = minetest.get_player_by_name(self._owner) if puncher then obj:punch(puncher, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 8}, }) end end end end if collided then self.object:remove() yl_nether.fired_table[self._owner] = nil end end }) ``` </details>
Member

doing an audit. so far, the bones entity is a possible culprit, fix: 79e338e914

doing an audit. so far, the bones entity is a possible culprit, fix: https://gitea.your-land.de/your-land/bones/commit/79e338e91491758c42b8b2522f8fc53e74439da8
Author
Owner

Why again did I add the QA label here way before the fix or even the reason became known?

Regardless: Is it fixed and testworthy?

Why again did I add the QA label here way before the fix or even the reason became known? Regardless: Is it fixed and testworthy?
Member

Why again did I add the QA label here way before the fix or even the reason became known?

Regardless: Is it fixed and testworthy?

yup, it's fixed. i turned the dumbfix into a real fix, because it's a reasonable way of handling that situation.

> Why again did I add the QA label here way before the fix or even the reason became known? > > Regardless: Is it fixed and testworthy? yup, it's fixed. i turned the dumbfix into a real fix, because it's a reasonable way of handling that situation.
AliasAlreadyTaken added the
ugh/QA OK
label 2023-02-10 19:43:23 +00:00
AliasAlreadyTaken modified the milestone from 1.1.117.1 to 1.1.118 2023-02-23 12:00:47 +00:00
flux added
5. result/fixed
and removed
4. step/ready to QA test
labels 2023-04-25 20:58:24 +00:00
Member

this is live

this is live
flux closed this issue 2023-04-25 20:58:30 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 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#3744
No description provided.