`/script run f() -> (game_tick(); f();); f();` crashes whole server sometimes
James103 opened this issue ยท 3 comments
When you run the following command, it has a chance not only failing with an exception (which should be printed out as "Your thoughts are too deep" implying a caught java.lang.StackOverflowError
), but crashing the entire server as well.
To reproduce:
- Start a new world with cheats enabled.
- Run the command
/script run f() -> (game_tick(); f();); f();
. - Notice that after a couple in-game minutes (few in-game seconds), the game may crash due to a variety of exceptions.
Crash reports generated from running the command in different environments:
java.lang.NoClassDefFoundError: Could not initialize class carpet.script.exception.ExpressionException
:
crash-2021-05-22_05.53.17-server.txtjava.lang.BootstrapMethodError: call site initialization exception
caused byjava.lang.StackOverflowError
:
crash-2021-05-22_05.58.32-server.txt- Sometimes, the command just errors out as expected with the following:
Your thoughts are too deep in system chat at pos 1
HERE>> f() -> (game_tick(); f();); f();
Error while evaluating expression
Marking invalid - you are calling tick after tick in a recursive manner - which will overtime build up a stack, possibly holding on to some wierd memory references causing the JVM to run out of allocable memory.
you should not call gametick from a gametick since that will cause the game_tick() to never finish. In some cases it works, but in some modded servers it crashes immediately even by just calling game_tick()