[SPIGOT-8038] Crash/OutOfMemoryError when calling addItem with AIR Created: 08/Apr/25 Updated: 13/Apr/25 Resolved: 13/Apr/25 |
|
| Status: | Resolved |
| Project: | Spigot |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Almighty-Satan | Assignee: | Unassigned |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | 1.21.4, 1.21.5, crash | ||
| Version: | CraftBukkit version 4479-Spigot-e339edc-f8f36c7 (MC: 1.21.5) (Implementing API version 1.21.5-R0.1-SNAPSHOT) |
| Guidelines Read: | Yes |
| Description |
|
When player.getInventory().addItem(new ItemStack(Material.AIR));
is called, the server immediately starts consuming all available memory and freezes. Players time out and the server thread appears to be dead. There is no immediate error message, but errors like Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Spigot Watchdog Thread" will start appearing after ~30 seconds. Sometimes the server also crashes completely with a thread dump. Minimal command example: @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof Player) ((Player) sender).getInventory().addItem(new ItemStack(Material.AIR)); return false; } I am aware that adding AIR to an inventory is pretty useless, but the server should not crash regardless. 1.21.4 appears to be also affected by this issue. |