Carpet

Carpet

2M Downloads

[Moderate bug, not too buggy, but still relativistically buggy] When running 'import' in the '__on_tick()' the game crashes

Ghoulboy78 opened this issue ยท 10 comments

commented
---- Minecraft Crash Report ----
// There are four lights!

Description: Exception in server tick loop

java.util.ConcurrentModificationException
	at java.util.ArrayList.removeIf(ArrayList.java:1411)
	at carpet.script.CarpetEventServer$CallbackList.call(CarpetEventServer.java:129)
	at carpet.script.CarpetEventServer$Event$1.onTick(CarpetEventServer.java:191)
	at net.minecraft.server.MinecraftServer.handler$zek000$tickTasks(MinecraftServer.java:3325)
	at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:827)
	at net.minecraft.class_1132.method_3748(class_1132.java:130)
	at net.minecraft.server.MinecraftServer.handler$zdl000$modifiedRunLoop(MinecraftServer.java:2897)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:634)
	at java.lang.Thread.run(Thread.java:745)
commented

What Minecraft and Carpet version were you running at the time of the crash, and what script did it crash in?

commented

1.15.2, latest carpet version

commented

I repeated and got the same result

commented

Actually, I was running 1.3.23. In 1.3.25, it waits for half a second, and THEN crashes.

---- Minecraft Crash Report ----
// Who set us up the TNT?

Description: Exception in server tick loop

java.util.ConcurrentModificationException
	at java.util.ArrayList.removeIf(ArrayList.java:1411)
	at carpet.script.CarpetEventServer$CallbackList.call(CarpetEventServer.java:129)
	at carpet.script.CarpetEventServer$Event$1.onTick(CarpetEventServer.java:191)
	at net.minecraft.server.MinecraftServer.handler$zek000$tickTasks(MinecraftServer.java:3325)
	at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:827)
	at net.minecraft.class_1132.method_3748(class_1132.java:130)
	at net.minecraft.server.MinecraftServer.handler$zdl000$modifiedRunLoop(MinecraftServer.java:2897)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:634)
	at java.lang.Thread.run(Thread.java:745)
commented

yeah, needs fixing. You should not be running imports in a tick loop anyways, but that is a bug.

commented

I can see clearily how this would happen, its not the import, but the fact that you are running some code that adds to the events while stuff gets removed from the events. Do you have a code that does that for you?

commented

Ok, I didn't quite understand that bit, so I'll explain wtf I did.
Basically, I have a library app, called useful_lib.sc. In said app, I have a global var, global_new_players which is a list of the new players which joined that tick. That changes in the beginning, as the app recognizes I'm logged in and thinks that I have just logged in, which I effectively have, and says hi. Though before it gets round to that, the game crashes. I think that's what you mean by

running some code that adds to the events while stuff gets removed from the events.

I modify it each tick based on which players are new. You can see the code in that pr to gnembon/scarpet#101. It is literally that code, but I just imported the global vars. But that only imported the initial state, so I tried importing each tick and it crashed.

SO instead I tried importing a func which returned the global var which was defined in useful_lib.sc, but that also worked, so I did a big brian think and asked. Ill see now if I can get that to work.

commented

ok there are three things I need to fix, I can see happening here.

commented

second thing: when you are importing from another module, you physically not interacting with that app, but making a copy of whatever is there as part of your app. The reason list is not updating, because your first app doesn't 'run' and update the other app. That other app (player locator) run once because of the import and that's it.

Currently by importing from another app you are effectively 'running it' which honestly shoudn't happen. You should not be able to automatically connect to events from other modules

commented

ok, removed ability to autoimport events when importing modules.
also - fixed so modifying event queue while executing events from the same queue doesn't cause concurrentmodiffication. Its probably really bad when this happens, but hey.