misc/wagon.lua:17: attempt to perform arithmetic on local 'damage' (a nil value) #1956

Closed
opened 2022-05-21 14:29:27 +00:00 by AliasAlreadyTaken · 5 comments

2022-05-21 16:28:10: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'petz' in callback luaentity_Punch(): ...5.5.1/Minetest_live/bin/../mods/petz/petz/misc/wagon.lua:17: attempt to perform arithmetic on local 'damage' (a nil value)
2022-05-21 16:28:10: ERROR[Main]: stack traceback:
2022-05-21 16:28:10: ERROR[Main]: ...5.5.1/Minetest_live/bin/../mods/petz/petz/misc/wagon.lua:17: in function 'func'
2022-05-21 16:28:10: ERROR[Main]: ...inetest_live/bin/../builtin/profiler/instrumentation.lua:107: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:100>

2022-05-21 16:28:10: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'petz' in callback luaentity_Punch(): ...5.5.1/Minetest_live/bin/../mods/petz/petz/misc/wagon.lua:17: attempt to perform arithmetic on local 'damage' (a nil value) 2022-05-21 16:28:10: ERROR[Main]: stack traceback: 2022-05-21 16:28:10: ERROR[Main]: ...5.5.1/Minetest_live/bin/../mods/petz/petz/misc/wagon.lua:17: in function 'func' 2022-05-21 16:28:10: ERROR[Main]: ...inetest_live/bin/../builtin/profiler/instrumentation.lua:107: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:100>
AliasAlreadyTaken added the
1. kind/bug
2. prio/critical
labels 2022-05-21 14:29:36 +00:00
Author
Owner

Here's the original:

on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
        if self.object:get_hp() - damage <= 0 then <--- line 17
                mokapi.drop_item(self, ItemStack("petz:wagon 1"))
        end
end

Here's my dumbfix:

on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
        if not damage then
                core.log("error","[#1956] damage ="..dump(damage))
                core.log("error","[#1956] puncher ="..dump(puncher))
                return
        end
        if self.object:get_hp() - damage <= 0 then
                mokapi.drop_item(self, ItemStack("petz:wagon 1"))
        end
end
Here's the original: ```lua on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage) if self.object:get_hp() - damage <= 0 then <--- line 17 mokapi.drop_item(self, ItemStack("petz:wagon 1")) end end ``` Here's my dumbfix: ```lua on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage) if not damage then core.log("error","[#1956] damage ="..dump(damage)) core.log("error","[#1956] puncher ="..dump(puncher)) return end if self.object:get_hp() - damage <= 0 then mokapi.drop_item(self, ItemStack("petz:wagon 1")) end end ```
flux added the
ugh/petz
label 2022-10-28 01:49:25 +00:00
Member

@AliasAlreadyTaken any idea what triggered this?

@AliasAlreadyTaken any idea what triggered this?
Author
Owner

Not the slightest. It hasn't happened ever since, my dumbfix isn't in the code anymore. I don't see why damage would ever become nil.

https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L2158

Except when something calls the function directly. Wouldn't such a direct call appear in stacktrace?

Not the slightest. It hasn't happened ever since, my dumbfix isn't in the code anymore. I don't see why damage would ever become nil. https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L2158 Except when something calls the function directly. Wouldn't such a direct call appear in stacktrace?
Member

Except when something calls the function directly. Wouldn't such a direct call appear in stacktrace?

this was very much triggered by the engine, w/ the damage value being nil, and i don't understand how or why that would happen. as the dumbfix has been removed, and we've upgraded the engine, let's keep this issue open for the moment, and close after a couple months if it doesn't occur again.

> Except when something calls the function directly. Wouldn't such a direct call appear in stacktrace? this was very much triggered by the engine, w/ the damage value being `nil`, and i don't understand how or why that would happen. as the dumbfix has been removed, and we've upgraded the engine, let's keep this issue open for the moment, and close after a couple months if it doesn't occur again.
Author
Owner

Let's do it the other way round: Close "cannot reproduce" and reopen when it occurs again. Because ... I will forget about this even tomorrow, let alone in a couple of month :D

Let's do it the other way round: Close "cannot reproduce" and reopen when it occurs again. Because ... I will forget about this even tomorrow, let alone in a couple of month :D
AliasAlreadyTaken added the
5. result/cannot reproduce
label 2022-11-02 12:12:23 +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#1956
No description provided.