clientcommands icon indicating copy to clipboard operation
clientcommands copied to clipboard

Client command `alias` can stack overflow and crash

Open James103 opened this issue 4 years ago • 1 comments

As of Client Commands version 2.5.4 for Minecraft 1.17.1, running the following commands will produce a stack overflow:

calias add a b
calias add b a
a

This generates the following error:

Error on recursive calias
java.util.regex.PatternSyntaxException: Stack overflow during pattern compilation near index 3
(?<!%)%(?:%%)*(?!%)
   ^
	at java.base/java.util.regex.Pattern.error(Pattern.java:2028)
	at java.base/java.util.regex.Pattern.<init>(Pattern.java:1432)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1069)
	at net.earthcomputer.clientcommands.command.AliasCommand.executeAliasCommand(AliasCommand.java:78)
	at net.earthcomputer.clientcommands.command.AliasCommand.lambda$addAlias$10(AliasCommand.java:119)
	at net.earthcomputer.clientcommands.command.AliasCommand$$Lambda$8038/0x00000000ebe88d68.run(Unknown Source)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:263)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:177)
	at net.earthcomputer.clientcommands.command.ClientCommandManager.executeCommand(ClientCommandManager.java:73)
	at net.minecraft.class_746.handler$znm001$onSendChatMessage(class_746.java:3291)
	at net.minecraft.class_746.method_3142(class_746.java)
	at net.earthcomputer.clientcommands.command.AliasCommand.executeAliasCommand(AliasCommand.java:95)
	at net.earthcomputer.clientcommands.command.AliasCommand.lambda$addAlias$10(AliasCommand.java:119)
	at net.earthcomputer.clientcommands.command.AliasCommand$$Lambda$8038/0x00000000ebe88d68.run(Unknown Source)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:263)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:177)
	at net.earthcomputer.clientcommands.command.ClientCommandManager.executeCommand(ClientCommandManager.java:73)
	at net.minecraft.class_746.handler$znm001$onSendChatMessage(class_746.java:3291)
	at net.minecraft.class_746.method_3142(class_746.java)
	at net.earthcomputer.clientcommands.command.AliasCommand.executeAliasCommand(AliasCommand.java:95)
	at net.earthcomputer.clientcommands.command.AliasCommand.lambda$addAlias$10(AliasCommand.java:119)
	at net.earthcomputer.clientcommands.command.AliasCommand$$Lambda$8038/0x00000000ebe88d68.run(Unknown Source)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:263)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:177)
	at net.earthcomputer.clientcommands.command.ClientCommandManager.executeCommand(ClientCommandManager.java:73)
	at net.minecraft.class_746.handler$znm001$onSendChatMessage(class_746.java:3291)
	at net.minecraft.class_746.method_3142(class_746.java)
	at net.earthcomputer.clientcommands.command.AliasCommand.executeAliasCommand(AliasCommand.java:95)
	at net.earthcomputer.clientcommands.command.AliasCommand.lambda$addAlias$10(AliasCommand.java:119)
	at net.earthcomputer.clientcommands.command.AliasCommand$$Lambda$8038/0x00000000ebe88d68.run(Unknown Source)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:263)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:177)
	at net.earthcomputer.clientcommands.command.ClientCommandManager.executeCommand(ClientCommandManager.java:73)
	at net.minecraft.class_746.handler$znm001$onSendChatMessage(class_746.java:3291)
	at net.minecraft.class_746.method_3142(class_746.java)
...
	at net.earthcomputer.clientcommands.command.AliasCommand.executeAliasCommand(AliasCommand.java:95)
	at net.earthcomputer.clientcommands.command.AliasCommand.lambda$addAlias$10(AliasCommand.java:119)
	at net.earthcomputer.clientcommands.command.AliasCommand$$Lambda$8038/0x00000000ebe88d68.run(Unknown Source)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:263)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:177)
	at net.earthcomputer.clientcommands.command.ClientCommandManager.executeCommand(ClientCommandManager.java:73)
	at net.minecraft.class_746.handler$znm001$onSendChatMessage(class_746.java:3291)
	at net.minecraft.class_746.method_3142(class_746.java)
	at net.minecraft.class_437.method_25425(class_437.java:376)
	at net.minecraft.class_437.method_25427(class_437.java:369)
	at net.minecraft.class_408.method_25404(class_408.java:101)
	at net.minecraft.class_309.method_1454(class_309.java:374)
	at net.minecraft.class_309$$Lambda$8008/0x00000000ebe7d898.run(Unknown Source)
	at net.minecraft.class_437.method_25412(class_437.java:490)
	at net.minecraft.class_309.method_1466(class_309.java:370)
	at net.minecraft.class_309.method_22678(class_309.java:462)
	at net.minecraft.class_309$$Lambda$7999/0x00000000eb560c80.run(Unknown Source)
	at net.minecraft.class_1255.execute(class_1255.java:101)
	at net.minecraft.class_309.method_22676(class_309.java:462)
	at net.minecraft.class_309$$Lambda$3555/0x00000000bc0955b8.invoke(Unknown Source)
	at org.lwjgl.glfw.GLFWKeyCallbackI.callback(GLFWKeyCallbackI.java:37)
	at org.lwjgl.system.JNI.invokeV(Native Method)
	at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101)
	at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:172)
	at net.minecraft.class_1041.method_15998(class_1041.java:310)
	at net.minecraft.class_310.method_1523(class_310.java:1137)
	at net.minecraft.class_310.method_1514(class_310.java:728)
	at net.minecraft.client.main.Main.main(Main.java:217)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:234)
	at net.fabricmc.loader.launch.knot.Knot.launch(Knot.java:153)
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:210)
	at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:245)
	at org.multimc.EntryPoint.listen(EntryPoint.java:143)
	at org.multimc.EntryPoint.main(EntryPoint.java:34)

System Details from F3+L profiling: system.txt


I managed to crash Minecraft by running the same alias command again: crash-2021-09-22_19.31.38-client.txt

James103 avatar Sep 23 '21 00:09 James103

Can't reproduce in Client Commands 2.7 and Fabric API 0.57.0 on Minecraft 1.19 if the "dotone" mod is installed. Instead, when running the above commands, server-side command parsing fails with "Unknown or incomplete command" when executing b on the command line.

James103 avatar Jul 25 '22 22:07 James103