-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Ghost entities #13297
Comments
In what way? Error message?
What do you mean? I thought removing them was not possible. |
Yes, an "attempt to index a nil value" error (referring to a line like
Sorry, I wasn't clear enough: I remove the entity but then, for some reason, the |
All entity references returned by the engine have the metatable set, so it's not possible that a method is nil. I would investigate other mods you have and check if they do some advanced things like operate with fake players. From your description the following should reproduce it but I can indeed find nothing wrong: -- use with /spawnentity
minetest.register_entity("test2:thing", {
initial_properties = {
visual = "cube",
textures = {"smoke_puff.png", "smoke_puff.png", "smoke_puff.png",
"smoke_puff.png", "smoke_puff.png", "smoke_puff.png"},
static_save = false,
},
on_activate = function(self, staticdata, dtime_s)
self.timer = 0
self.object:set_attach(core.get_player_by_name("singleplayer"))
end,
on_step = function(self, dtime, moveresult)
self.timer = self.timer + dtime
if self.timer > 2 then
local parent = self.object:get_attach()
self.object:remove()
print("we were attached to " .. tostring(parent))
local children = parent:get_children()
print("which has " .. #children .. " children now:")
for _, obj in ipairs(children) do
local line = " " .. tostring(obj)
if obj:get_hp() == nil then
line = line .. " (broken ref)"
end
if obj == self.object then
line = line .. " <- this is us"
end
print(line)
end
end
end,
}) |
this may not be related, but on the your-land server, since 5.6.0 or 5.6.1, we've noticed that occasionally the results of |
FWIW I think this should still be tagged "unconfirmed bug" because nobody has posted the actual code they used in connection with the bug, nor the actual error message. |
Happened to me as well and it doesn't seem to be related to children entities in particular https://gitlab.com/zughy-friends-minetest/block_league/-/issues/133. Server and client 5.8.0 Basically someone hit an entity that wasn't really there anymore. |
"Attempt to index a nil value" on a line like I don't think this makes much sense, but we return a HP of 1 (!) for invalid entities: minetest/src/script/lua_api/l_object.cpp Lines 248 to 252 in fe6da3a
We should probably deprecate this behavior. A check like I believe minetest/src/script/lua_api/l_object.cpp Line 848 in fe6da3a
I think this once again demonstrates how much of a footgun invalid object refs are, hence is possibly related to #14687
This sounds like invalid object refs. See the linked issue and also this MTG issue. To sum it up: While you are iterating your objects and doing something to them (say, punching them), other objects may be invalidated. A classic example would be blowing up an entity with attached entities. The parent may kill its children, leaving you with invalid object refs. This issue is not fixable without changing the API or adding a new API: These functions return lists. They can't remove objects from these lists after the fact (okay, technically they could, but that would be a potentially inefficient mess). A proper design requires an iterator which skips invalidated objects. FWIW, so far I can not find a bug in |
Yes, please. That would have avoided my crash (since entities are obtained through a for loop of a raycast) |
Tagging this possible close as outlined in #14769 (comment) |
Minetest version
OS / Hardware
Operating system: Ubuntu 22.04.2 LTS
CPU: Intel(R) Xeon(R) CPU E5-2630 v4 4core
Summary
Sometimes calling
get_children()
on a player returns entities with almost no methods except forget_hp()
andis_player()
. This is a problem because if you try to call any other method (such asremove()
), the game crashes.Steps to reproduce
I haven't found a way to reproduce this. What I know is that the "ghost" entities are not attached to the player anymore, because they disappear after I remove them (from within their on_step callback). May this bug be somewhat lag-related?
The text was updated successfully, but these errors were encountered: