YUNG-GANG / YUNGs-Cave-Biomes

Minecraft mod that adds new cave biomes and underground content
Other
3 stars 2 forks source link

ThreadLocalRandom accessed from a different thread (C2ME forge) #17

Open Dreaming-Codes opened 2 hours ago

Dreaming-Codes commented 2 hours ago

Hi,

I'm experiencing a problem on my server where it eventually crashes. The issue seems to arise from a java.util.ConcurrentModificationException, specifically related to ThreadLocalRandom being accessed from a different thread than its owner. Here's a snippet of the error message:

java.util.ConcurrentModificationException: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: ForkJoinPool.commonPool-worker-16)
    at com.ishland.c2me.fixes.worldgen.threading_issues.common.CheckedThreadLocalRandom.handleNotOwner(CheckedThreadLocalRandom.java:55) ~[c3me-fabric-mc1.20.1-0.2.0-c3me-alpha.11.69$c2me-fixes-worldgen-threading-issues-mc1.20.1-0.2.0-c3me-alpha.11.69_mapped_srg_1.20.1.jar%23966!/:?]
    at com.ishland.c2me.fixes.worldgen.threading_issues.common.CheckedThreadLocalRandom.isSafe(CheckedThreadLocalRandom.java:38) ~[c3me-fabric-mc1.20.1-0.2.0-c3me-alpha.11.69$c2me-fixes-worldgen-threading-issues-mc1.20.1-0.2.0-c3me-alpha.11.69_mapped_srg_1.20.1.jar%23966!/:?]
    at com.ishland.c2me.fixes.worldgen.threading_issues.common.CheckedThreadLocalRandom.m_64707_(CheckedThreadLocalRandom.java:86) ~[c3me-fabric-mc1.20.1-0.2.0-c3me-alpha.11.69$c2me-fixes-worldgen-threading-issues-mc1.20.1-0.2.0-c3me-alpha.11.69_mapped_srg_1.20.1.jar%23966!/:?]
    at net.minecraft.world.level.levelgen.BitRandomSource.m_188503_(BitRandomSource.java:33) ~[server-1.20.1-20230612.114412-srg.jar%23435!/:?]
    at net.minecraft.util.Mth.m_216287_(net/minecraft/util/Mth.java:734) ~[server-1.20.1-20230612.114412-srg.jar%23435!/:?]
    at com.yungnickyoung.minecraft.yungscavebiomes.block.entity.RareIceBlockEntity.tick(RareIceBlockEntity.java:23) ~[YungsCaveBiomes-1.20.1-Forge-2.0.1.jar%23432!/:1.20.1-Forge-2.0.1]
    at net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity.mixinextras$bridge$m_155252_$11(LevelChunk.java) ~[server-1.20.1-20230612.114412-srg.jar%23435!/:?]
    at net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity.wrapOperation$bfd000$tt20$onTick(net/snackbag/tt20/mixin/world/WorldChunkMixin.java [tt20.mixins.json]:24) ~[server-1.20.1-20230612.114412-srg.jar%23435!/:?]
    at net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity.m_142224_(net/minecraft/world/level/chunk/LevelChunk$BoundTickingBlockEntity.java:689) ~[server-1.20.1-20230612.114412-srg.jar%23435!/:?]
    at net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper.m_142224_(LevelChunk.java:782) ~[server-1.20.1-20230612.114412-srg.jar%23435!/:?]
    at me.thegiggitybyte.sleepwarp.runnable.BlockTickRunnable.run(BlockTickRunnable.java:17) ~[sleepwarp-2.2.0_rc1+1.20.1_mapped_srg_1.20.1.jar%23988!/:?]
    at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) ~[?:?]
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) ~[?:?]
    at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) ~[?:?]
    at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) ~[?:?]
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) ~[?:?]
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) ~[?:?]
[25Oct2024 17:47:53.737] [ForkJoinPool.commonPool-worker-17/ERROR] [CheckedThreadLocalRandom/]: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: ForkJoinPool.commonPool-worker-17)
This is usually NOT a bug in C2ME, but a bug in another mod or in vanilla code. 
Possible solutions: 
  - Find possible causes in the stack trace below and 
    - if caused by another mod, report this to the corresponding mod authors 
    - if no other mods are involved, report this to C2ME 

This error message is repeatedly logged, leading to the server becoming unresponsive and crashing after about a minute. Occasionally, the issue resolves itself without a crash, but this is rare.

I'm using the C2ME port from this repository: C2ME-fabric 1.20.1 with Synatra connector.

For more details, you can view the full log here: Log File.

Dreaming-Codes commented 2 hours ago

16 might be related

Dreaming-Codes commented 2 hours ago

I'm also using https://github.com/AnOpenSauceDev/FastRandom which uses ThreadLocalRandom under the hood so it may be related

yungnickyoung commented 2 hours ago

Huh, that's weird. Accessing the level random should be safe from a block entity. In fact, vanilla does this exact same thing in SculkShriekerBlockEntity#playWardenReplySound, so I'm assuming my usage is also not a problem

Dreaming-Codes commented 1 hour ago

Huh, that's weird. Accessing the level random should be safe from a block entity. In fact, vanilla does this exact same thing in SculkShriekerBlockEntity#playWardenReplySound, so I'm assuming my usage is also not a problem

Just removed FastRandom I'll let you know if I notice any difference