YUNG-GANG / YUNGs-Cave-Biomes

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

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

Closed Dreaming-Codes closed 13 hours ago

Dreaming-Codes commented 1 month 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 1 month ago

16 might be related

Dreaming-Codes commented 1 month ago

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

yungnickyoung commented 1 month 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 month 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

Dreaming-Codes commented 1 month ago

@yungnickyoung Just encountered the same issue even without FastRandom https://mclo.gs/vCTs4Wb

java.util.ConcurrentModificationException: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: ForkJoinPool.commonPool-worker-37)
    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%23961!/:?]
    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%23961!/:?]
    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%23961!/:?]
    at net.minecraft.world.level.levelgen.BitRandomSource.m_188503_(BitRandomSource.java:33) ~[server-1.20.1-20230612.114412-srg.jar%23433!/:?]
    at net.minecraft.util.Mth.m_216287_(net/minecraft/util/Mth.java:734) ~[server-1.20.1-20230612.114412-srg.jar%23433!/:?]
    at com.yungnickyoung.minecraft.yungscavebiomes.block.entity.RareIceBlockEntity.tick(RareIceBlockEntity.java:23) ~[YungsCaveBiomes-1.20.1-Forge-2.0.1.jar%23430!/: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%23433!/:?]
    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%23433!/:?]
    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%23433!/:?]
    at net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper.m_142224_(LevelChunk.java:782) ~[server-1.20.1-20230612.114412-srg.jar%23433!/:?]
    at me.thegiggitybyte.sleepwarp.runnable.BlockTickRunnable.run(BlockTickRunnable.java:17) ~[sleepwarp-2.2.0_rc1+1.20.1_mapped_srg_1.20.1.jar%23982!/:?]
    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) ~[?:?]
[26Oct2024 11:07:48.790] [Server thread/INFO] [de.mrjulsen.crn.CreateRailwaysNavigator/]: All times have been corrected: 3 Ticks
[26Oct2024 11:07:48.947] [Server thread/INFO] [de.mrjulsen.crn.CreateRailwaysNavigator/]: All times have been corrected: 3 Ticks
[26Oct2024 11:07:49.069] [Server thread/INFO] [de.mrjulsen.crn.CreateRailwaysNavigator/]: All times have been corrected: 2 Ticks
[26Oct2024 11:07:49.076] [ForkJoinPool.commonPool-worker-38/ERROR] [CheckedThreadLocalRandom/]: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: ForkJoinPool.commonPool-worker-38)
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 
Dreaming-Codes commented 1 month ago

I've developed a mod that mixin into yours to disable that method. If anyone else is experiencing this issue and need an immediate solution, you can download the mod here: GitHub - Dreaming-Codes/fix-yungs-cave-biomes/releases.

Dreaming-Codes commented 1 month ago

Okay nvm, it seams that the problem was due to the sleepwarp mod running via connector, I'll keep this issue open for a day or two more just to be sure it's solved

CaoTrongThang commented 1 month ago

Okay nvm, it seams that the problem was due to the sleepwarp mod running via connector, I'll keep this issue open for a day or two more just to be sure it's solved

i might don't understand but i need to download the fix-yungs-cave-biomes mod to fix my current bug right?

CaoTrongThang commented 1 month ago

Okay nvm, it seams that the problem was due to the sleepwarp mod running via connector, I'll keep this issue open for a day or two more just to be sure it's solved

i might don't understand but i need to download the fix-yungs-cave-biomes mod to fix my current bug right?

yungnickyoung commented 21 hours ago

Okay nvm, it seams that the problem was due to the sleepwarp mod running via connector, I'll keep this issue open for a day or two more just to be sure it's solved

@Dreaming-Codes Just to verify, was this resolved?

Dreaming-Codes commented 13 hours ago

Okay nvm, it seams that the problem was due to the sleepwarp mod running via connector, I'll keep this issue open for a day or two more just to be sure it's solved

@Dreaming-Codes Just to verify, was this resolved?

Yes sorry I forgot, I can confirm it was due to the sleepwarp mod running with Synatra connector