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

Minecraft Server doesn't catch any java.lang.Error on the player's command execution

XMLWordPrintable

    • Plausible
    • Commands, Dedicated Server

      Description of bug

      I am creating a command to be used in the mod; the logic to throw a special java.lang.Throwable that is able to throw in the runtime such as java.lang.Error is defined in the command, and I did not implement any handling exceptions.

      The problem is that when Minecraft Server handles execution of the command sent by the player, it doesn't handle any java.lang.Error. Meanwhile, if the command is entered in the console of Dedicated Server, the server makes a crash as intended.

      To reproduce, we should use a modified Minecraft version in the present, but it may also happen enough in the Vanilla environment.

      Step to reproduce

      On Integrated Server (Singleplayer world)

      1. Install Fabric to the client
      2. Apply the mod in Attachment 1 to move under .minecraft/mods directory
      3. Also apply Fabric API mod
      4. Creating a new world or join existing
      5. Enter test command
      6. See the server doesn't make a crash and continues

      On Dedicated Server

      1. Install Fabric Server
      2. Apply the mod in Attachment 1 to move under .minecraft/mods directory
      3. Also apply Fabric API mod
      4. Write script to run the server and execute it
      5. Agree the EULA and re-run the server
      6. Check the server has done the startup and join the server
      7. Enter test command
      8. See the server doesn't make a crash and continues

      Expected result

      Server crashes and makes a crash report.

      Attachments

      Attachment 1

      [command/crash-test] 1.0.0-SNAPSHOT for Fabric
      The test mod to reproduce the bug.

      Command Information

      Command Syntax

      • test

      Attachment 2

      TestCommand.java

      import com.mojang.brigadier.CommandDispatcher;
      import net.fabricmc.api.ModInitializer;
      import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
      import net.minecraft.command.CommandRegistryAccess;
      import net.minecraft.server.command.CommandManager;
      import net.minecraft.server.command.ServerCommandSource;
      
      public class TestCommand implements ModInitializer, CommandRegistrationCallback {
      	@Override
      	public void onInitialize() {
      		CommandRegistrationCallback.EVENT.register(this);
      	}
      
      	@Override
      	public void register(
      			CommandDispatcher<ServerCommandSource> dispatcher,
      			CommandRegistryAccess registryAccess,
      			CommandManager.RegistrationEnvironment environment
      	) {
      		dispatcher.register(
      				CommandManager.literal("test")
      						.requires(source -> source.hasPermissionLevel(CommandManager.field_31841))
      						.executes(ctx -> {
      							throw new Error("Manually triggered debug crash");
      						})
      		);
      	}
      }
      

      Source code of the test mod.

            Unassigned Unassigned
            NoEul NoEul
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: