[2.1.9] Crash calling transfer_from_stack on item-on-ground
Posted: Thu Jul 02, 2026 8:04 am
Create a mod that adds the following command and execute it twice:
Result:
The item-on-ground is still shown as marked for deconstruction, but the iron-plate sprite is gone. When hovering over it with the mouse, the game crashes.
In my actual scenario where this happened, I can call buggy.stack.clear() sometimes to avoid the crash, but this does not reproduce in this test code (will produce a "LuaEntity was invalid" error instead and not crash)
Code: Select all
commands.add_command("test_game_crash", nil, function(command)
-- NOTE: Does not crash and removes the item-on-ground if transfer_from_stack is called immediately after entity creation
local buggy = game.surfaces["nauvis"].find_entity("item-on-ground", {0, 0})
if buggy then
local inv_1 = game.create_inventory(10)
inv_1.transfer_from_stack(buggy.stack)
game.print(buggy.gps_tag..": Hover me to crash the game")
else
buggy = game.surfaces["nauvis"].create_entity {
name = "item-on-ground",
position = {0, 0},
stack = { name = "iron-plate", count = 1 }
}
buggy.order_deconstruction(game.forces.player)
end
end)The item-on-ground is still shown as marked for deconstruction, but the iron-plate sprite is gone. When hovering over it with the mouse, the game crashes.
In my actual scenario where this happened, I can call buggy.stack.clear() sometimes to avoid the crash, but this does not reproduce in this test code (will produce a "LuaEntity was invalid" error instead and not crash)