Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-218112

SynchedEntityData is using locks incorrectly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 1.17 Pre-release 1
    • 1.16.5, 21w08b
    • None
    • Plausible
    • Crash, Networking
    • Very Important

      The bug

      Inside the Entity SynchedEntityData (or also known as DataTracker) class it is trying to use read-write locks to synchronize the internal maps access. Only some methods do correctly use a try-finally block to correctly ensure that at the end of the Method the lock is back to unlocked.

      Especially noteworthy is the assignValues method, which is not using try-finally, and calls the assignValue method that has a throw IllegalStateException in case of incompatible data. So any time that exception is thrown, the lock of this SynchedEntityData is left in a locked state, potentially causing a deadlock/crash.

      Currently, this behavior can be seen on the official Minecraft partner server CubeCraft. At least when playing in 1.16.5, all arrows sent by their server contain invalid data and cause this bug to lock the SynchedEntityData of all arrows.

      java.lang.IllegalStateException: Invalid entity data item type for field 8 on entity bgc['Arrow'/16059, l='ClientLevel', x=0.21, y=8.52, z=14.79]: old=0(class java.lang.Byte), new=-1(class java.lang.Integer)
      

      I've also checked snapshot 21w08b, where this issue has not been resolved yet.

            slicedlime [Mojang] slicedlime
            tr7zw tr7zw
            Votes:
            6 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: