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

Concurrent error crashes server when command block runs a command that creates or unloads a world

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • This server is running CraftBukkit version 3540-Spigot-56be6a8-0231a37 (MC: 1.19) (Implementing API version 1.19-R0.1-SNAPSHOT)
    • Yes

      This report is based on Paper#6072.

      The attached plugin adds the command /testloadworld, which runs the following code:

          @Override
          public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
              World world = WorldCreator.name("testworld")
                      .environment(World.Environment.NORMAL)
                      .type(WorldType.NORMAL)
                      .createWorld();
      
              getLogger().info(String.valueOf(world));
      
              return true;
          }
      

      When a player or the console runs this command, a new world is created without issue. However, when a command block runs the command, the server promptly crashes after the world is created with the following error:

      [11:05:37] [Server thread/ERROR]: Encountered an unexpected exception
      java.util.ConcurrentModificationException: null
          at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:756) ~[?:?]
          at java.util.LinkedHashMap$LinkedValueIterator.next(LinkedHashMap.java:783) ~[?:?]
          at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1273) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3540-Spigot-56be6a8-0231a37]
          at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:394) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3540-Spigot-56be6a8-0231a37]
          at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1197) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3540-Spigot-56be6a8-0231a37]
          at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:1010) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3540-Spigot-56be6a8-0231a37]
          at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:291) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3540-Spigot-56be6a8-0231a37]
          at java.lang.Thread.run(Thread.java:833) [?:?]
       

      The paper issue mentioned above was resolved by this pull request, which adds a check to make sure a world is not created while the worlds are being ticked. This explains the issue to developers more clearly with the following exception:

      java.lang.IllegalStateException: Cannot create a world while worlds are being ticked 

      Even though this issue was resolved by Paper, a similar fix should probably exist for Spigot. Throwing an error that explains why the crash happens would be helpful. I don't know if this already exsists, but it would also be helpful if there was a method plugin developers could use to tell if the worlds are being ticked so they can avoid triggering this crash in the first place

            Unassigned Unassigned
            WillKroboth Will Kroboth
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: