Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6413

Server Corruption Changing Blocks in Piston Events

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • Mac OS

    • git-Bukkit-0791e54 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
    • Yes

      Trying to fix some exploits in my plugin, I tried switching out blocks inside of the PistonExtendEvent. Specifically I was replacing the air block the piston head was about to extend into with a shulker box.

      I think this ends up creating a block without a corresponding tile entity. I'm trying to make a clean reproduction case for this part and it may require some special handling to fix the root problem, but my first and easier suggestion is to catch the fallout.

      I got the "... Bukkit will attempt to fix this, but there may be additional damage that we cannot recover" message and then the server shut down.

      The server is now stuck in a crash loop anytime this chunk loads. The reason is here, in WorldServer.fixTileEntity:

       

      TileEntity replacement = ((ITileEntity) type).createTile(this);
      replacement.setLocation(this, pos);
      this.setTileEntity(pos, replacement);
      return replacement;
      

      For a piston head (and possibly other blocks?) createTile returns null, and so a null check is needed here. I suggest:

       

       

      if (type instanceof ITileEntity) {
          TileEntity replacement = ((ITileEntity) type).createTile(this);
          if (replacement != null) {
              replacement.setLocation(this, pos);
              this.setTileEntity(pos, replacement);
          }
          return replacement;
      } else {
          return found;
      }
      

      I am trying to make a PR for this but recently got a new dev machine and makePatches.sh is not working for me.

      Note that I initially tried mimicking the current behavior and returning "found" instead of null, but this just causes a log spam loop forever. I'm wondering if this should also return null for the existing case of not "type instanceof ITileEntity", or else I think it just keeps hitting this check forever.

      Sorry for this mess of a report, but I wanted to at least make people aware since this situation can be pretty catastrophic for a server if they happen to get in this situation.

       

            Unassigned Unassigned
            NathanWolf Nathan Wolf
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: