Crash/OutOfMemoryError when calling addItem with AIR

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major
    • None
    • Affects Version/s: None
    • CraftBukkit version 4479-Spigot-e339edc-f8f36c7 (MC: 1.21.5) (Implementing API version 1.21.5-R0.1-SNAPSHOT)
    • Yes

      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.

            Assignee:
            Unassigned
            Reporter:
            Almighty-Satan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: