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

Sneaking while a NaN velocity is applied causes hang & crash

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • Spigot: git-Spigot-3fb9445-6e3cec8

      Plugins:  Plugins (1): SimplePlugin (For demonstration / reproduction)

      Perhaps this should be classified as major/private? It can cause a crash pretty easily depending on circumstances.

       

      I was able to crash the server by doing the following while crouched:

      p.setVelocity(new Vector(Double.NaN, Double.NaN, Double.NaN));

       

      Tested on a freshly build Spigot with 0 plugin except for a barebones plugin to set my velocity to NaN. ONLY seems to happen when sneaking? I can't do it any other way, hangs immediately upon setting velocity while crouching.

      A typical thread dump from this hang: https://hastebin.com/jigoyutaro.md - Sometimes has a few lines about BlockStairs and whatnot in there as well.

       

      Proposed fix:

      Adding this to the top of setVelocity in CraftEntity fixes the issue.

      if (Double.isNaN(vel.getX())) vel.setX(0);
      if (Double.isNaN(vel.getY())) vel.setY(0);
      if (Double.isNaN(vel.getZ())) vel.setZ(0);

       

      (Maybe set to current velocity if current isn't NaN? I tried doing this without the check and some players reported "Infinite ascension")

      Perhaps add some sort of warning or message like the excessive velocity warning, but for NaN velocities?

      Without this fix I was crashing 5-10 times a day, with the fix I haven't crashed in the last 72 hours. The cause of the NaN velocities was a misconfigured Mythic Mob, but this can still be an issue for other plugins that aren't safely checking velocities before setting them.

            Unassigned Unassigned
            Joannou1 Johnny Joannou
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: