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

Exceptions in the gameLoopFunction crash the server

XMLWordPrintable

    • Confirmed

      The bug

      If an exception occurs in any command run by the gameLoopFunction, the server will crash. As vanilla commands usually do not throw exceptions, this issue will mostly cause problems on custom servers or other modified versions of the game.

      Expected behavior

      When the player executes the same function from chat, the exception is shown in chat and the server continues running. Something similar should happen for the gameLoopFunction, e.g. logging the exception when it occurs.

      How to reproduce

      1. Create a new function.
      2. Add a command to the function that will throw an exception.
        • In 17w45a, the execute command will cause a NullPointerException when used inside a function (see MC-121674).
        • This is just an example, any exception occurring during command execution will work.
      3. (Optional) Run the function from chat. The exception will be shown in chat, but otherwise nothing happens.
      4. Set that function as the gameLoopFunction. The server will crash immediately.

      Provided by jirauser71590:

      [13:35:50] [Server thread/ERROR]: Couldn't execute command for @: teleport @e[x=-170,y=55,z=-115,dx=0,dy=5,dz=17,type=minecraft:villager] -150 55 -90
      com.mojang.brigadier.exceptions.CommandSyntaxException: No entity was found
              at com.mojang.brigadier.exceptions.SimpleCommandExceptionType.create(SimpleCommandExceptionType.java:28) ~[minecraft_server.jar:?]
              at bp.b(SourceFile:51) ~[minecraft_server.jar:?]
              at oq.f(SourceFile:46) ~[minecraft_server.jar:?]
              at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:117) ~[minecraft_server.jar:?]
              at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:74) ~[minecraft_server.jar:?]
              at bl.a(SourceFile:169) [minecraft_server.jar:?]
              at aot.a(SourceFile:118) [minecraft_server.jar:?]
              at ary.c(SourceFile:248) [minecraft_server.jar:?]
              at ary.a(SourceFile:120) [minecraft_server.jar:?]
              at ary.b(SourceFile:93) [minecraft_server.jar:?]
              at pu.a(SourceFile:641) [minecraft_server.jar:?]
              at pu.d(SourceFile:220) [minecraft_server.jar:?]
              at net.minecraft.server.MinecraftServer.w(SourceFile:648) [minecraft_server.jar:?]
              at pf.w(SourceFile:349) [minecraft_server.jar:?]
              at net.minecraft.server.MinecraftServer.v(SourceFile:584) [minecraft_server.jar:?]
              at net.minecraft.server.MinecraftServer.run(SourceFile:489) [minecraft_server.jar:?]
              at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
      [13:35:50] [Server thread/ERROR]: Encountered an unexpected exception
      java.lang.NullPointerException: null
              at oe.a(SourceFile:404) ~[minecraft_server.jar:?]
              at oe.o(SourceFile:66) ~[minecraft_server.jar:?]
              at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:117) ~[minecraft_server.jar:?]
              at bh$b.a(SourceFile:82) ~[minecraft_server.jar:?]
              at mm$a.a(SourceFile:187) ~[minecraft_server.jar:?]
              at mm.a(SourceFile:104) ~[minecraft_server.jar:?]
              at mm.N_(SourceFile:80) ~[minecraft_server.jar:?]
              at net.minecraft.server.MinecraftServer.w(SourceFile:678) ~[minecraft_server.jar:?]
              at pf.w(SourceFile:349) ~[minecraft_server.jar:?]
              at net.minecraft.server.MinecraftServer.v(SourceFile:584) ~[minecraft_server.jar:?]
              at net.minecraft.server.MinecraftServer.run(SourceFile:489) [minecraft_server.jar:?]
              at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
      [13:35:50] [Server thread/ERROR]: This crash report has been saved to: D:\Users\Steven\Desktop\Minecraft\Server\.\crash-reports\crash-2017-11-10_13.35.50-server.txt
      [13:35:50] [Server thread/INFO]: Stopping server
      [13:35:50] [Server thread/INFO]: Saving players
      [13:35:50] [Server thread/INFO]: Saving worlds
      [13:35:50] [Server thread/INFO]: Saving chunks for level 'medabots_server'/overworld
      [13:35:50] [Server thread/INFO]: Saving chunks for level 'medabots_server'/the_nether
      [13:35:50] [Server thread/INFO]: Saving chunks for level 'medabots_server'/the_end
      [13:35:50] [Server Shutdown Thread/INFO]: Stopping server
      [13:35:50] [Server Shutdown Thread/INFO]: Saving players
      [13:35:50] [Server Shutdown Thread/INFO]: Saving worlds
      [13:35:50] [Server Shutdown Thread/INFO]: Saving chunks for level 'medabots_server'/overworld
      [13:35:50] [Server Shutdown Thread/INFO]: Saving chunks for level 'medabots_server'/the_nether
      [13:35:50] [Server Shutdown Thread/INFO]: Saving chunks for level 'medabots_server'/the_end
      
      D:\Users\Steven\Desktop\Minecraft\Server>pause
      Press any key to continue . . .

            dinnerbone [Mojang] Nathan Adams
            Somin Somin
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: