Carpet

Carpet

2M Downloads

`/script run f() -> (game_tick(); f();); f();` crashes whole server sometimes

James103 opened this issue ยท 3 comments

commented

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:

  1. Start a new world with cheats enabled.
  2. Run the command /script run f() -> (game_tick(); f();); f();.
  3. 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:

Your thoughts are too deep in system chat at pos 1
 HERE>> f() -> (game_tick(); f();); f();
Error while evaluating expression
commented

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.

commented

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()

commented

I know you are not calling the game_tick() from the gametick, but you don't let the stack unfold by recursing it.