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: mod bones - server crash when use 'minetest.punch_node()' from any mod #3145

Closed
berengma opened this issue Jul 27, 2024 · 3 comments · Fixed by #3146
Closed

Bug: mod bones - server crash when use 'minetest.punch_node()' from any mod #3145

berengma opened this issue Jul 27, 2024 · 3 comments · Fixed by #3146
Labels

Comments

@berengma
Copy link
Contributor

berengma commented Jul 27, 2024

Version:

Minetest 5.8.0 (Linux)
Using LuaJIT 2.1.0-beta3
BUILD_TYPE=Release
RUN_IN_PLACE=0
USE_CURL=1
STATIC_SHAREDIR="/usr/local/share/minetest"

Error message from log:

2024-07-27 01:58:25: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'bones' in callback luaentity_Step(): "Runtime error from mod 'bones' in callback node_on_punch(): ...l/share/minetest/games/minetest_game/mods/bones/init.lua:100: attempt to index local 'player_inv' (a ni
2024-07-27 01:58:25: ERROR[Main]: l value)
2024-07-27 01:58:25: ERROR[Main]: stack traceback:
2024-07-27 01:58:25: ERROR[Main]:       ...l/share/minetest/games/minetest_game/mods/bones/init.lua:100: in function <...l/share/minetest/games/minetest_game/mods/bones/init.lua:85>
2024-07-27 01:58:25: ERROR[Main]:       [C]: in function 'punch_node'

reproduction:

  • just minetest game and a a mod using the 'minetest.punch_node(pos)' method
  • player with something in inv dies
  • use a mod with the described method and use it on the pos of the placed bones
  • server crashes with above message

possible solution:

  • In init.lua line 85 not only check for owner but maybe check also for player:sPlayer() ?
@sfan5 sfan5 added the Bug label Jul 27, 2024
@SmallJoker
Copy link
Member

Reproduced by spawning new bones (do not place manually).

minetest.register_chatcommand("p", {
	func = function(name, param)
		local pos = minetest.get_player_by_name(name):get_pos()

		local node_name = #param > 0 and param or "bones:bones"
		local np = minetest.find_node_near(pos, 4, node_name, true)
		if not np then
			return false, "No node found"
		end
		minetest.punch_node(np)
		return true, "OK!"
	end
})

Even though the Lua API states that puncher may be nil, but the C++ side creates an empty ObjectRef, which in turn does not have an inventory.

What is the expected result? Would you like to remove the node and destroy all of its contents, drop the contents as item entities, or disallow any interaction?

@berengma
Copy link
Contributor Author

Difficult to say what the expected result is. Depends on the mod which uses the method.
Disallowing any interaction is probably not what I wanted to have, when I wrote a bone harvester mod.
Removing the node and destroy everything is something the involving mod could handle by itself.
I think dropping the contents and removing the bones node would be the best option. Thinking in terms of what other mods could do with the results.

berengma pushed a commit to berengma/minetest_game that referenced this issue Jul 30, 2024
@berengma
Copy link
Contributor Author

see PR #3146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants