DenisD3D / Mc2Discord

Link your Minecraft server chat with your Discord (75k downloads)
https://modrinth.com/mod/mc2discord
Apache License 2.0
43 stars 11 forks source link

C2ME giving ThreadLocalRandom warning with Mc2Discord #114

Open elitesdead opened 1 month ago

elitesdead commented 1 month ago

Describe the bug

Describe the bug: There is no crash or serious problem, but the following log appears in console. Everything otherwise works as intended, but I am wondering if there is a way to prevent this from showing up?

To Reproduce Steps to reproduce the behavior:

  1. Use Mc2Discord and configure the ability to use commands from Discord server.
  2. When using a "/give" command from the Discord server, the command works, but throws a warning error "An unexpected error occurred trying to execute that command." in the Discord channel.
  3. Go to console to see error message.

Expected behavior "An unexpected error occurred trying to execute that command" should not appear in the channel which Mc2Discord is connected to when using "/give" commands. Preferably no error message in console.

OS: Windows 10 Minecraft version: 1.21 Version of Mc2Discord: mc2discord-fabric-1.21.x-4.2.4.jar

Crash reports / logs

[02:43:35] [d4j-events-68/ERROR]: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: d4j-events-68)
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

java.util.ConcurrentModificationException: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: d4j-events-68)
    at com.ishland.c2me.fixes.worldgen.threading_issues.common.CheckedThreadLocalRandom.handleNotOwner(CheckedThreadLocalRandom.java:55) ~[c2me-fixes-worldgen-threading-is11.106+1.21-81a7270bfcefabcc.jar:?]
    at com.ishland.c2me.fixes.worldgen.threading_issues.common.CheckedThreadLocalRandom.isSafe(CheckedThreadLocalRandom.java:38) ~[c2me-fixes-worldgen-threading-is11.106+1.21-81a7270bfcefabcc.jar:?]
    at com.ishland.c2me.fixes.worldgen.threading_issues.common.CheckedThreadLocalRandom.method_43156(CheckedThreadLocalRandom.java:86) ~[c2me-fixes-worldgen-threading-is11.106+1.21-81a7270bfcefabcc.jar:?]
    at net.minecraft.class_6566.method_43058(class_6566.java:61) ~[server-intermediary.jar:?]
    at net.minecraft.class_1542.<init>(net/minecraft/class_1542.java:71) ~[server-intermediary.jar:?]
    at net.minecraft.class_1657.method_7329(net/minecraft/class_1657.java:762) ~[server-intermediary.jar:?]
    at net.minecraft.class_3222.method_7329(net/minecraft/class_3222.java:1846) ~[server-intermediary.jar:?]
    at net.minecraft.class_1657.method_7328(net/minecraft/class_1657.java:747) ~[server-intermediary.jar:?]
    at net.minecraft.class_3068.method_13401(class_3068.java:74) ~[server-intermediary.jar:?]
    at net.minecraft.class_3068.method_13403(class_3068.java:42) ~[server-intermediary.jar:?]
    at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73) ~[brigadier-1.2.9.jar:?]
    at net.minecraft.class_8865.method_54416(class_8865.java:29) ~[server-intermediary.jar:?]
    at net.minecraft.class_8865.execute(class_8865.java:13) ~[server-intermediary.jar:?]
    at net.minecraft.class_8856.method_54405(class_8856.java:8) ~[server-intermediary.jar:?]
    at net.minecraft.class_8847.method_54388(class_8847.java:8) ~[server-intermediary.jar:?]
    at net.minecraft.class_8854.method_54390(class_8854.java:107) ~[server-intermediary.jar:?]
    at net.minecraft.class_2170.method_54313(net/minecraft/class_2170.java:379) ~[server-intermediary.jar:?]
    at net.minecraft.class_2170.method_9249(net/minecraft/class_2170.java:309) ~[server-intermediary.jar:?]
    at net.minecraft.class_2170.method_44252(net/minecraft/class_2170.java:299) ~[server-intermediary.jar:?]
    at fr.denisd3d.mc2discord.minecraft.MinecraftImpl.executeCommand(MinecraftImpl.java:142) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.core.events.DiscordEvent.processCommand(DiscordEvent.java:81) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.core.events.DiscordEvent.onMessageCreate(DiscordEvent.java:58) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.LambdaSubscriber.onNext(LambdaSubscriber.java:160) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.tryOnNext(FluxContextWrite.java:115) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxDoFinally$DoFinallyConditionalSubscriber.tryOnNext(FluxDoFinally.java:172) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.tryOnNext(FluxPeekFuseable.java:530) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxHandleFuseable$HandleFuseableConditionalSubscriber.tryOnNext(FluxHandleFuseable.java:559) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.tryOnNext(FluxMapFuseable.java:317) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.tryOnNext(FluxFilterFuseable.java:367) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxPublishOn$PublishOnConditionalSubscriber.runAsync(FluxPublishOn.java:992) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.shadow.reactor.core.publisher.FluxPublishOn$PublishOnConditionalSubscriber.run(FluxPublishOn.java:1067) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.shadow.reactor.scheduler.forkjoin.ForkJoinPoolScheduler$DisposableWorkerTask.run(ForkJoinPoolScheduler.java:443) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at fr.denisd3d.mc2discord.shadow.reactor.scheduler.forkjoin.ForkJoinPoolScheduler$Worker.processTaskQueue(ForkJoinPoolScheduler.java:407) ~[mc2discord-fabric-1.21.x-4.2.4.jar:?]
    at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423) [?:?]
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) [?:?]
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) [?:?]
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) [?:?]
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) [?:?]
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) [?:?]

Other mods https://pastebin.com/CCimkmFw

Additional context When I reported this to C2ME, they replied with "It is because Mc2Discord isn't running commands on the server thread. It should be reported to Mc2Discord instead." Is there something that can be done with this?

Your config file

http://m2d.denisd3d.fr/uploads/view?key=c7a28f86-5028-45a7-a382-0bafabf7ee89

DenisD3D commented 1 month ago

Looks like c2me is complaining about peanuts things :) Will see if I can easily move that code to the main thread in the next update so c2me is happy

elitesdead commented 1 month ago

Thank you!

DenisD3D commented 1 month ago

Keeping open to remember to fix in next update