moving-piston will throw ArrayIndexOutOfBoundsException and crash the server
sakurawald opened this issue ยท 2 comments
See here PaperMC/Paper#8018, still encounter this bug in 1.20.1
Maybe try this case: build a piston (normal or sticky, only 1 piston is enough), and then keep this piston running. Then build a nether portal nearby, and wait random times. StarLight will receive a ChunkPos#toLong = -1, and then crash the server.
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 33
at it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap.rehash(Long2ObjectOpenHashMap.java:1297)
at it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap.insert(Long2ObjectOpenHashMap.java:249)
at it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap.computeIfAbsent(Long2ObjectOpenHashMap.java:449)
at net.minecraft.class_6609.method_38644(class_6609.java:28) # SimulationDistanceLevelPropagator.getTickets
at net.minecraft.class_6609.method_38637(class_6609.java:36) # SimulationDistanceLevelPropagator.add
at net.minecraft.class_3204.method_17291(class_3204.java:187) # ChunkTicketManager.addTicket
at net.minecraft.class_3215.method_17297(class_3215.java:456) # ServerChunkManager.addTicket
at net.minecraft.class_3227.queueTaskForSection(class_3227.java:1590)
at net.minecraft.class_3227.method_15513(class_3227.java:1617)
at net.minecraft.class_2818.method_12010(class_2818.java:255)
at net.minecraft.class_1937.method_30092(class_1937.java:228) # Level.java
at net.minecraft.class_1937.method_8652(class_1937.java:213) # Level.java
at net.minecraft.class_2669.redirect$zib000$carpet$movableTEsetBlockState0(class_2669.java:593)
at net.minecraft.class_2669.method_31707(class_2669.java:324)
at net.minecraft.class_2818$class_5563.redirect$zcf000$carpet$checkProcessBEs(class_2818.java:790)
at net.minecraft.class_2818$class_5563.method_31703(class_2818.java:662)
at net.minecraft.class_2818$class_5564.method_31703(class_2818.java:716)
at net.minecraft.class_1937.method_18471(class_1937.java:470)
at net.minecraft.class_3218.method_18765(class_3218.java:390)
at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:897)
at net.minecraft.class_3176.method_3813(class_3176.java:283)
at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:824)
at net.minecraft.server.MinecraftServer.handler$zcc000$carpet$modifiedRunLoop(MinecraftServer.java:8942)
at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:650)
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265)
at java.base/java.lang.Thread.run(Thread.java:833)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Thread: Server thread
Stacktrace:
at it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap.rehash(Long2ObjectOpenHashMap.java:1297)
at it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap.insert(Long2ObjectOpenHashMap.java:249)
at it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap.computeIfAbsent(Long2ObjectOpenHashMap.java:449)
at net.minecraft.class_6609.method_38644(class_6609.java:28)
at net.minecraft.class_6609.method_38637(class_6609.java:36)
at net.minecraft.class_3204.method_17291(class_3204.java:187)
at net.minecraft.class_3215.method_17297(class_3215.java:456)
at net.minecraft.class_3227.queueTaskForSection(class_3227.java:1590)
at net.minecraft.class_3227.method_15513(class_3227.java:1617)
at net.minecraft.class_2818.method_12010(class_2818.java:255)
at net.minecraft.class_1937.method_30092(class_1937.java:228)
at net.minecraft.class_1937.method_8652(class_1937.java:213)
at net.minecraft.class_2669.redirect$zib000$carpet$movableTEsetBlockState0(class_2669.java:593)
at net.minecraft.class_2669.method_31707(class_2669.java:324)
at net.minecraft.class_2818$class_5563.redirect$zcf000$carpet$checkProcessBEs(class_2818.java:790)
at net.minecraft.class_2818$class_5563.method_31703(class_2818.java:662)
at net.minecraft.class_2818$class_5564.method_31703(class_2818.java:716)
at net.minecraft.class_1937.method_18471(class_1937.java:470)
at net.minecraft.class_3218.method_18765(class_3218.java:390)
-- Block entity being ticked --
Details:
Name: minecraft:piston // net.minecraft.class_2669
Block: Block{minecraft:moving_piston}[facing=south,type=normal]
Block location: World: (26150,70,22688), Section: (at 6,6,0 in 1634,4,1418; chunk contains blocks 26144,-64,22688 to 26159,319,22703), Region: (51,44; contains chunks 1632,1408 to 1663,1439, blocks 26112,-64,22528 to 26623,319,23039)
Block: Block{minecraft:observer}[facing=south,powered=false]
Block location: World: (26150,70,22688), Section: (at 6,6,0 in 1634,4,1418; chunk contains blocks 26144,-64,22688 to 26159,319,22703), Region: (51,44; contains chunks 1632,1408 to 1663,1439, blocks 26112,-64,22528 to 26623,319,23039)
Stacktrace:
at net.minecraft.class_2818$class_5563.method_31703(class_2818.java:662)
at net.minecraft.class_2818$class_5564.method_31703(class_2818.java:716)
at net.minecraft.class_1937.method_18471(class_1937.java:470)
at net.minecraft.class_3218.method_18765(class_3218.java:390)
at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:897)
at net.minecraft.class_3176.method_3813(class_3176.java:283)
at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:824)
at net.minecraft.server.MinecraftServer.handler$zcc000$carpet$modifiedRunLoop(MinecraftServer.java:8942)
at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:650)
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265)
at java.base/java.lang.Thread.run(Thread.java:833)
PS: you can just ignore stack movableTEsetBlockState0
, because i never turn on this piston feature in carpet, so this carpet method-redirect works the same as vanilla.
Something is modifying ticket levels async. Starlight always schedules these to happen on the main server thread. It's likely that the repeated ticket additions from Starlight (which is to ensure that chunks do not unload during lighting, which Vanilla doesn't do) is revealing a race condition caused by an improperly programmed mod.
You can find out which mod is doing this by inserting a thread check (i.e at-Inject on HEAD) into DistanceManager for all methods that modify the tickets field (i.e put, computeIfAbsent, remove, etc). The thread check: (mojang mappings)
@Unique private boolean failsCheck() { return !((BlockableEventLoop)this.mainThreadExecutor).isSameThread(); }in a mixin on DistanceManager.java
I think you are right, finally, i found that an async teleport from other mods will cause this to happen.
Something is modifying ticket levels async. Starlight always schedules these to happen on the main server thread. It's likely that the repeated ticket additions from Starlight (which is to ensure that chunks do not unload during lighting, which Vanilla doesn't do) is revealing a race condition caused by an improperly programmed mod.
You can find out which mod is doing this by inserting a thread check (i.e at-Inject on HEAD) into DistanceManager for all methods that modify the tickets field (i.e put, computeIfAbsent, remove, etc). The thread check:
(mojang mappings)
@Unique
private boolean failsCheck() {
return !((BlockableEventLoop)this.mainThreadExecutor).isSameThread();
}
in a mixin on DistanceManager.java