gnembon / fabric-carpet

Fabric Carpet
MIT License
1.73k stars 275 forks source link

Server crash using rand: Accessing LegacyRandomSource from multiple threads #1710

Closed Hellhium closed 1 year ago

Hellhium commented 1 year ago

Crash happened while running a command from a scarpet script

Scarpet script:

__config() -> {
    'stay_loaded' -> true,
    'scope' -> 'global',
    'command_permission' -> 'ops',
    'commands' -> {
        'dovote <player>' -> _(to) -> _runwithply(to),
        'givetoken <player>' -> _(to) -> _giveVoteToken(to),
    },
   'arguments' -> {
      'player' -> {'type' -> 'players', 'single' -> true}
   }
};

_giveVoteToken(ply) -> run(str('give %s firework_star{display:{Name:\'[{"text":"Token de vote","italic":false}]\',Lore:[\'[{"text":"Un token obtenu en votant","italic":false}]\',\'[{"text":"Faites bien attention de ne pas l\\\'utiliser dans un craft","italic":false}]\']},Enchantments:[{}]} 1', ply));

_runwithply(ply) ->
(
   run(str('scoreboard players add %s votes 1', ply));
   _giveVoteToken(ply);
   roll = floor(rand(6))+1;
   print(str('Vote pour %s enregistré, roll: %d', ply, roll));
   run(str('tellform %s <c:>[Votes]</c> <gray>Merci d\'avoir voté, votre jet de dé est: %d</gray>', ply, roll));
   if(roll == 6, _spawnWanderingTrader(ply););
);

_spawnWanderingTrader(ply) -> (
   run(str('tellform %s <c:>[Votes]</c> <gray>Votre 6 vous a octroyé un Wandering Trader</gray>', ply, roll));
   spawn('minecraft:wandering_trader', pos(player(ply)))
)

Crash dump:

---- Minecraft Crash Report ----
// Would you like a cupcake?

Time: 2023-04-23 13:47:46
Description: Accessing LegacyRandomSource from multiple threads

java.lang.IllegalStateException: Accessing LegacyRandomSource from multiple threads
    at net.minecraft.class_5798.method_33564(class_5798.java:84)
    at net.minecraft.class_5820.method_43156(class_5820.java:49)
    at net.minecraft.class_6566.method_43048(class_6566.java:27)
    at net.minecraft.class_3218.method_18203(class_3218.java:462)
    at net.minecraft.class_3215.method_14161(class_3215.java:380)
    at net.minecraft.class_3215.method_12127(class_3215.java:324)
    at net.minecraft.class_3218.method_18765(class_3218.java:319)
    at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:901)
    at net.minecraft.class_3176.method_3813(class_3176.java:283)
    at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:828)
    at net.minecraft.server.MinecraftServer.handler$zci000$carpet$modifiedRunLoop(MinecraftServer.java:7436)
    at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:654)
    at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:266)
    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 net.minecraft.class_5798.method_33564(class_5798.java:84)
    at net.minecraft.class_5820.method_43156(class_5820.java:49)
    at net.minecraft.class_6566.method_43048(class_6566.java:27)
    at net.minecraft.class_3218.method_18203(class_3218.java:462)
    at net.minecraft.class_3215.method_14161(class_3215.java:380)
    at net.minecraft.class_3215.method_12127(class_3215.java:324)
    at net.minecraft.class_3218.method_18765(class_3218.java:319)

-- Thread dumps --
Details:
    Thread dumps: Server thread: 
    at java.base/java.lang.Thread.getStackTrace(Thread.java:1610)
    at net.minecraft.class_5798.method_39936(class_5798.java:92)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
    at net.minecraft.class_5798.method_33564(class_5798.java:82)
    at net.minecraft.class_5820.method_43156(class_5820.java:49)
    at net.minecraft.class_6566.method_43048(class_6566.java:27)
    at net.minecraft.class_3218.method_18203(class_3218.java:462)
    at net.minecraft.class_3215.method_14161(class_3215.java:380)
    at net.minecraft.class_3215.method_12127(class_3215.java:324)
    at net.minecraft.class_3218.method_18765(class_3218.java:319)
    at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:901)
    at net.minecraft.class_3176.method_3813(class_3176.java:283)
    at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:828)
    at net.minecraft.server.MinecraftServer.handler$zci000$carpet$modifiedRunLoop(MinecraftServer.java:7436)
    at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:654)
    at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:266)
    at java.base/java.lang.Thread.run(Thread.java:833)
Stacktrace:
    at net.minecraft.class_5798.method_33564(class_5798.java:84)
    at net.minecraft.class_5820.method_43156(class_5820.java:49)
    at net.minecraft.class_6566.method_43048(class_6566.java:27)
    at net.minecraft.class_3218.method_18203(class_3218.java:462)
    at net.minecraft.class_3215.method_14161(class_3215.java:380)
    at net.minecraft.class_3215.method_12127(class_3215.java:324)
    at net.minecraft.class_3218.method_18765(class_3218.java:319)
    at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:901)
    at net.minecraft.class_3176.method_3813(class_3176.java:283)
    at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:828)
    at net.minecraft.server.MinecraftServer.handler$zci000$carpet$modifiedRunLoop(MinecraftServer.java:7436)
    at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:654)
    at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:266)
    at java.base/java.lang.Thread.run(Thread.java:833)

-- Affected level --
Details:
    All players: **redacted**
    Chunk stats: 19965
    Level dimension: minecraft:overworld
    Level spawn location: World: (-32,64,-48), Section: (at 0,0,0 in -2,4,-3; chunk contains blocks -32,-64,-48 to -17,319,-33), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,-64,-512 to -1,319,-1)
    Level time: 27598621 game time, 15024491 day time
    Level name: world
    Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
    Level weather: Rain time: 106692 (now: false), thunder time: 32937 (now: false)
    Known server brands: fabric
    Level was modded: true
    Level storage version: 0x04ABD - Anvil
Stacktrace:
    at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:901)
    at net.minecraft.class_3176.method_3813(class_3176.java:283)
    at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:828)
    at net.minecraft.server.MinecraftServer.handler$zci000$carpet$modifiedRunLoop(MinecraftServer.java:7436)
    at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:654)
    at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:266)
    at java.base/java.lang.Thread.run(Thread.java:833)

-- System Details --
Details:
    Minecraft Version: 1.19.4
    Minecraft Version ID: 1.19.4
    Operating System: Linux (amd64) version 5.10.0-21-amd64
    Java Version: 17.0.6, Eclipse Adoptium
    Java VM Version: OpenJDK 64-Bit Server VM (mixed mode, sharing), Eclipse Adoptium
    Memory: 5168744528 bytes (4929 MiB) / 10737418240 bytes (10240 MiB) up to 10737418240 bytes (10240 MiB)
    CPUs: 12
    Processor Vendor: AuthenticAMD
    Processor Name: AMD Ryzen 5 3600 6-Core Processor
    Identifier: AuthenticAMD Family 23 Model 113 Stepping 0
    Microarchitecture: Zen 2
    Frequency (GHz): -0.00
    Number of physical packages: 1
    Number of physical CPUs: 6
    Number of logical CPUs: 12
    Graphics card #0 name: unknown
    Graphics card #0 vendor: unknown
    Graphics card #0 VRAM (MB): 0.00
    Graphics card #0 deviceId: unknown
    Graphics card #0 versionInfo: unknown
    Virtual memory max (MB): 64884.53
    Virtual memory used (MB): 13943.90
    Swap memory total (MB): 32735.00
    Swap memory used (MB): 151.25
    JVM Flags: 20 total; -Xms10G -Xmx10G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1
    Loaded Scarpet Apps: 
        conqvote
    Fabric Mods: 
        antixray: AntiXray 1.3.0
            com_moandjiezana_toml_toml4j: toml4j 0.7.2
        armor-stand-editor: Armor Stand Editor 2.1.0+1.19.4-rc2
            common-protection-api: Common Protection API 1.0.0
            player-data-api: Player Data API 0.2.2+1.19.3
            server_translations_api: Server Translations API 2.0.0-beta.2+1.19.4-pre2
                packet_tweaker: Packet Tweaker 0.3.1+23w06a
            sgui: sgui 1.2.1+1.19.3
        audioplayer: AudioPlayer 1.19.4-1.5.1
        banhammer: BanHammer 0.6.4+1.19.3
            com_mysql_mysql-connector-j: mysql-connector-j 8.0.31
            org_postgresql_postgresql: postgresql 42.5.1
            org_xerial_sqlite-jdbc: sqlite-jdbc 3.40.0.0
        bluemap: BlueMap 3.13
        bluemapadvancedmarker: BlueMap Advanced Marker Addon 2022.10.1
            fabric-permissions-api-v0: fabric-permissions-api 0.2-SNAPSHOT
        carpet: Carpet Mod 1.4.101+v230319
        chunkpregen: Fabric Chunk Pregenerator 0.3.3
        editsign: EditSign 2.8.0
            cloth-config: Cloth Config v10 10.0.96
                cloth-basic-math: cloth-basic-math 0.6.1
        fabric-api: Fabric API 0.76.0+1.19.4
            fabric-api-lookup-api-v1: Fabric API Lookup API (v1) 1.6.24+49abcf7ef4
            fabric-biome-api-v1: Fabric Biome API (v1) 13.0.6+348a9c64f4
            fabric-block-api-v1: Fabric Block API (v1) 1.0.5+e022e5d1f4
            fabric-command-api-v1: Fabric Command API (v1) 1.2.25+f71b366ff4
            fabric-commands-v0: Fabric Commands (v0) 0.2.42+df3654b3f4
            fabric-containers-v0: Fabric Containers (v0) 0.1.52+df3654b3f4
            fabric-content-registries-v0: Fabric Content Registries (v0) 3.5.7+ae0966baf4
            fabric-convention-tags-v1: Fabric Convention Tags 1.4.0+9a7c5daaf4
            fabric-crash-report-info-v1: Fabric Crash Report Info (v1) 0.2.14+aeb40ebef4
            fabric-data-generation-api-v1: Fabric Data Generation API (v1) 11.3.5+5da15ca1f4
            fabric-dimensions-v1: Fabric Dimensions API (v1) 2.1.44+7f87f8faf4
            fabric-entity-events-v1: Fabric Entity Events (v1) 1.5.12+e45f7c65f4
            fabric-events-lifecycle-v0: Fabric Events Lifecycle (v0) 0.2.51+df3654b3f4
            fabric-game-rule-api-v1: Fabric Game Rule API (v1) 1.0.32+a1ccd7bff4
            fabric-item-api-v1: Fabric Item API (v1) 2.1.16+09a3510cf4
            fabric-item-group-api-v1: Fabric Item Group API (v1) 3.0.3+043f9acff4
            fabric-lifecycle-events-v1: Fabric Lifecycle Events (v1) 2.2.14+5da15ca1f4
            fabric-loot-api-v2: Fabric Loot API (v2) 1.1.25+75e98211f4
            fabric-loot-tables-v1: Fabric Loot Tables (v1) 1.1.29+9e7660c6f4
            fabric-message-api-v1: Fabric Message API (v1) 5.1.0+1ee8be40f4
            fabric-mining-level-api-v1: Fabric Mining Level API (v1) 2.1.37+49abcf7ef4
            fabric-networking-v0: Fabric Networking (v0) 0.3.39+df3654b3f4
            fabric-object-builder-api-v1: Fabric Object Builder API (v1) 7.0.1+63b515f4f4
            fabric-particles-v1: Fabric Particles (v1) 1.0.22+f1e4495bf4
            fabric-recipe-api-v1: Fabric Recipe API (v1) 1.0.6+a1ccd7bff4
            fabric-registry-sync-v0: Fabric Registry Sync (v0) 2.1.2+a383ab97f4
            fabric-rendering-data-attachment-v1: Fabric Rendering Data Attachment (v1) 0.3.27+afca2f3ef4
            fabric-rendering-fluids-v1: Fabric Rendering Fluids (v1) 3.0.20+f1e4495bf4
            fabric-resource-conditions-api-v1: Fabric Resource Conditions API (v1) 2.3.0+e6c7d4eef4
            fabric-resource-loader-v0: Fabric Resource Loader (v0) 0.11.0+938a1d56f4
            fabric-screen-handler-api-v1: Fabric Screen Handler API (v1) 1.3.18+5da15ca1f4
            fabric-transfer-api-v1: Fabric Transfer API (v1) 3.0.1+9003cbe9f4
            fabric-transitive-access-wideners-v1: Fabric Transitive Access Wideners (v1) 3.0.2+63b515f4f4
        fabric-language-kotlin: Fabric Language Kotlin 1.9.3+kotlin.1.8.20
            org_jetbrains_kotlin_kotlin-reflect: kotlin-reflect 1.8.20
            org_jetbrains_kotlin_kotlin-stdlib: kotlin-stdlib 1.8.20
            org_jetbrains_kotlin_kotlin-stdlib-jdk7: kotlin-stdlib-jdk7 1.8.20
            org_jetbrains_kotlin_kotlin-stdlib-jdk8: kotlin-stdlib-jdk8 1.8.20
            org_jetbrains_kotlinx_atomicfu-jvm: atomicfu-jvm 0.20.1
            org_jetbrains_kotlinx_kotlinx-coroutines-core-jvm: kotlinx-coroutines-core-jvm 1.6.4
            org_jetbrains_kotlinx_kotlinx-coroutines-jdk8: kotlinx-coroutines-jdk8 1.6.4
            org_jetbrains_kotlinx_kotlinx-datetime-jvm: kotlinx-datetime-jvm 0.4.0
            org_jetbrains_kotlinx_kotlinx-serialization-cbor-jvm: kotlinx-serialization-cbor-jvm 1.5.0
            org_jetbrains_kotlinx_kotlinx-serialization-core-jvm: kotlinx-serialization-core-jvm 1.5.0
            org_jetbrains_kotlinx_kotlinx-serialization-json-jvm: kotlinx-serialization-json-jvm 1.5.0
        fabricloader: Fabric Loader 0.14.19
        ferritecore: FerriteCore 5.2.0
        fsit: FSit v1.0.1
            fabric-events-interaction-v0: Fabric Events Interaction (v0) 0.4.42+a1ccd7bff4
            fabric-networking-api-v1: Fabric Networking API (v1) 1.2.22+ca5f59aaf4
        globalpacks: Global Data- & Resourcepacks 1.16_fabric
            com_electronwill_night-config_core: core 3.6.5
            com_electronwill_night-config_toml: toml 3.6.5
        java: OpenJDK 64-Bit Server VM 17
        ledger: Ledger 1.2.7
        lithium: Lithium 0.11.1
        luckperms: LuckPerms 5.4.66
        luckperms-placeholders: LuckPerms Placeholders 5.4-SNAPSHOT
        minecraft: Minecraft 1.19.4
        minecraft-command-permissions: Minecraft Command Permissions 1.6.1
        mmode: Maintenance Mode 1.1.0
            org_apache_commons_commons-compress: commons-compress 1.21
        nochatreports: No Chat Reports 1.19.4-v2.1.1
            fabric-api-base: Fabric API Base 0.4.23+9ff28bced8
        phosphor: Phosphor 0.8.1
        sdlink: Simple Discord Link 2.2.1
        spark: spark 1.10.34
        styledchat: Styled Chat 2.1.3+1.19.3
            placeholder-api: Placeholder API 2.0.0-rc.1+1.19.3
            predicate-api: Predicate API 0.1.0+1.19.3
        styledplayerlist: Styled Player List 2.3.0+1.19.3
        voicechat: Simple Voice Chat 1.19.4-2.4.2
            fabric-command-api-v2: Fabric Command API (v2) 2.2.4+ae0966bad8
        votifier: Fabric Votifier 1.1.5
            javax_xml_bind_jaxb-api: jaxb-api 2.2.4
            org_yaml_snakeyaml: snakeyaml 1.28
    Server Running: true
    Player Count: 11 / 30; **readctad**
    Data Packs: vanilla, AllMobHeads_V7.2.zip (incompatible), afk display v1.1.3.zip, anti enderman grief v1.1.3.zip, fabric, player head drops v1.1.3.zip, silence mobs v1.1.3.zip, track raw statistics v1.5.3.zip, track statistics v1.1.4.zip, unlock all recipes v2.0.4.zip, villager workstation highlights v1.1.3.zip, wandering trades v1.6.0.zip
    Enabled Feature Flags: minecraft:vanilla
    World Generation: Stable
    Is Modded: Definitely; Server brand changed to 'fabric'
    Type: Dedicated Server (map_server.txt)
James103 commented 1 year ago

Are you able to reproduce this crash with https://modrinth.com/mod/uwrad installed on the server? If so, please post the resulting crash report.

Hellhium commented 1 year ago

Crash only happened once so far, uwrad is now installed, will update the issue if it crashes again

Hellhium commented 1 year ago

Got it !

Fabric votifier config for completeness

port: 25865
enabled: true
commands: ['conqvote dovote %PLAYER%']

UWRAD stack trace:

[18:42:06] [Thread-14/ERROR]: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: Thread-14)
Possible solutions: Find possible causes in the stack trace below and report to the corresponding mod authors 

java.util.ConcurrentModificationException: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: Thread-14)
        at com.ishland.uwrad.common.CheckedThreadLocalRandom.handleNotOwner(CheckedThreadLocalRandom.java:51) ~[unsafe-world-random-access-detector-1.1.0.jar:?]
        at com.ishland.uwrad.common.CheckedThreadLocalRandom.isSafe(CheckedThreadLocalRandom.java:38) ~[unsafe-world-random-access-detector-1.1.0.jar:?]
        at com.ishland.uwrad.common.CheckedThreadLocalRandom.method_43156(CheckedThreadLocalRandom.java:82) ~[unsafe-world-random-access-detector-1.1.0.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:59) ~[server-intermediary.jar:?]
        at net.minecraft.class_1657.method_7329(net/minecraft/class_1657.java:722) ~[server-intermediary.jar:?]
        at net.minecraft.class_3222.method_7329(net/minecraft/class_3222.java:1616) ~[server-intermediary.jar:?]
        at net.minecraft.class_1657.method_7328(net/minecraft/class_1657.java:707) ~[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.CommandDispatcher.execute(com/mojang/brigadier/CommandDispatcher.java:263) ~[brigadier-1.0.18.jar:?]
        at net.minecraft.class_2170.method_9249(net/minecraft/class_2170.java:285) ~[server-intermediary.jar:?]
        at net.minecraft.class_2170.method_44252(net/minecraft/class_2170.java:278) ~[server-intermediary.jar:?]
        at carpet.script.api.Auxiliary.lambda$apply$26(Auxiliary.java:687) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression$17.lazyEval(Expression.java:684) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.execute(FunctionValue.java:271) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.callInContext(FunctionValue.java:163) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.Functions$1.lazyEval(Functions.java:60) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.ControlFlow.lambda$apply$5(ControlFlow.java:36) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression$16.lazyEval(Expression.java:652) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.execute(FunctionValue.java:271) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.callInContext(FunctionValue.java:163) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.Functions$1.lazyEval(Functions.java:60) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.execute(FunctionValue.java:271) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.lambda$call$28(CarpetScriptHost.java:869) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.evalValue(Expression.java:1034) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.call(CarpetScriptHost.java:868) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.lambda$handleCommand$21(CarpetScriptHost.java:723) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.utils.GlocalFlag.whileValueReturn(GlocalFlag.java:44) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.utils.GlocalFlag.getWhileDisabled(GlocalFlag.java:30) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.handleCommand(CarpetScriptHost.java:723) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.execute(CarpetScriptHost.java:153) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.lambda$addPathToCommand$3(CarpetScriptHost.java:177) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at com.mojang.brigadier.CommandDispatcher.execute(com/mojang/brigadier/CommandDispatcher.java:263) ~[brigadier-1.0.18.jar:?]
        at net.minecraft.class_2170.method_9249(net/minecraft/class_2170.java:285) ~[server-intermediary.jar:?]
        at net.minecraft.class_2170.method_44252(net/minecraft/class_2170.java:278) ~[server-intermediary.jar:?]
        at me.drex.votifier.VoteReceiver.run(VoteReceiver.java:121) ~[fabric-votifier-1.1.5.jar:?]
Hellhium commented 1 year ago

More information about that, it seems that the spawn() function is causing problems


[08:29:49] [Thread-14/INFO]: Vote pour 2Djis enregistré, roll: 6
[08:29:49] [Thread-14/ERROR]: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: Thread-14)
Possible solutions: Find possible causes in the stack trace below and report to the corresponding mod authors 

java.util.ConcurrentModificationException: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: Thread-14)
        at com.ishland.uwrad.common.CheckedThreadLocalRandom.handleNotOwner(CheckedThreadLocalRandom.java:51) ~[unsafe-world-random-access-detector-1.1.0.jar:?]
        at com.ishland.uwrad.common.CheckedThreadLocalRandom.isSafe(CheckedThreadLocalRandom.java:38) ~[unsafe-world-random-access-detector-1.1.0.jar:?]
        at com.ishland.uwrad.common.CheckedThreadLocalRandom.method_43156(CheckedThreadLocalRandom.java:82) ~[unsafe-world-random-access-detector-1.1.0.jar:?]
        at net.minecraft.class_6566.method_43058(class_6566.java:61) ~[server-intermediary.jar:?]
        at net.minecraft.class_5819.method_43385(class_5819.java:75) ~[server-intermediary.jar:?]
        at net.minecraft.class_1308.method_5943(net/minecraft/class_1308.java:1087) ~[server-intermediary.jar:?]
        at net.minecraft.class_1296.method_5943(class_1296.java:46) ~[server-intermediary.jar:?]
        at net.minecraft.class_3988.method_5943(class_3988.java:66) ~[server-intermediary.jar:?]
        at carpet.script.api.Entities.lambda$apply$5(Entities.java:155) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression$17.lazyEval(Expression.java:684) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.ControlFlow.lambda$apply$2(ControlFlow.java:28) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression$5.lazyEval(Expression.java:364) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$17(Expression.java:1504) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.execute(FunctionValue.java:271) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.callInContext(FunctionValue.java:163) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.Functions$1.lazyEval(Functions.java:60) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.ControlFlow.lambda$apply$9(ControlFlow.java:55) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression$15.lazyEval(Expression.java:614) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.ControlFlow.lambda$apply$5(ControlFlow.java:38) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression$16.lazyEval(Expression.java:652) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.execute(FunctionValue.java:271) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.callInContext(FunctionValue.java:163) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.Functions$1.lazyEval(Functions.java:60) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.execute(FunctionValue.java:271) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.lambda$call$28(CarpetScriptHost.java:869) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.evalValue(Expression.java:1034) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.call(CarpetScriptHost.java:868) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.lambda$handleCommand$21(CarpetScriptHost.java:723) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.utils.GlocalFlag.whileValueReturn(GlocalFlag.java:44) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.utils.GlocalFlag.getWhileDisabled(GlocalFlag.java:30) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.handleCommand(CarpetScriptHost.java:723) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.execute(CarpetScriptHost.java:153) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.lambda$addPathToCommand$3(CarpetScriptHost.java:177) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at com.mojang.brigadier.CommandDispatcher.execute(com/mojang/brigadier/CommandDispatcher.java:263) ~[brigadier-1.0.18.jar:?]
        at net.minecraft.class_2170.method_9249(net/minecraft/class_2170.java:285) ~[server-intermediary.jar:?]
        at net.minecraft.class_2170.method_44252(net/minecraft/class_2170.java:278) ~[server-intermediary.jar:?]
        at me.drex.votifier.VoteReceiver.run(VoteReceiver.java:121) ~[fabric-votifier-1.1.5.jar:?]
[08:29:49] [Thread-14/ERROR]: Unexpected exception while running Scarpet code
com.ishland.uwrad.common.CheckedThreadLocalRandom$1: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: Thread-14)
Possible solutions: Find possible causes in the stack trace below and report to the corresponding mod authors 

 (You may make this a fatal warning instead of a hard crash with enforce_safe_world_random_access setting in uwrad.properties)
Caused by: java.util.ConcurrentModificationException: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: Thread-14)
        at com.ishland.uwrad.common.CheckedThreadLocalRandom.handleNotOwner(CheckedThreadLocalRandom.java:51) ~[unsafe-world-random-access-detector-1.1.0.jar:?]
        at com.ishland.uwrad.common.CheckedThreadLocalRandom.isSafe(CheckedThreadLocalRandom.java:38) ~[unsafe-world-random-access-detector-1.1.0.jar:?]
        at com.ishland.uwrad.common.CheckedThreadLocalRandom.method_43156(CheckedThreadLocalRandom.java:82) ~[unsafe-world-random-access-detector-1.1.0.jar:?]
        at net.minecraft.class_6566.method_43058(class_6566.java:61) ~[server-intermediary.jar:?]
        at net.minecraft.class_5819.method_43385(class_5819.java:75) ~[server-intermediary.jar:?]
        at net.minecraft.class_1308.method_5943(net/minecraft/class_1308.java:1087) ~[server-intermediary.jar:?]
        at net.minecraft.class_1296.method_5943(class_1296.java:46) ~[server-intermediary.jar:?]
        at net.minecraft.class_3988.method_5943(class_3988.java:66) ~[server-intermediary.jar:?]
        at carpet.script.api.Entities.lambda$apply$5(Entities.java:155) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression$17.lazyEval(Expression.java:684) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.ControlFlow.lambda$apply$2(ControlFlow.java:28) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression$5.lazyEval(Expression.java:364) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$17(Expression.java:1504) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.execute(FunctionValue.java:271) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.callInContext(FunctionValue.java:163) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.Functions$1.lazyEval(Functions.java:60) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.ControlFlow.lambda$apply$9(ControlFlow.java:55) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression$15.lazyEval(Expression.java:614) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.ControlFlow.lambda$apply$5(ControlFlow.java:38) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression$16.lazyEval(Expression.java:652) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.execute(FunctionValue.java:271) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.callInContext(FunctionValue.java:163) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.language.Functions$1.lazyEval(Functions.java:60) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.lambda$extractOp$20(Expression.java:1513) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.value.FunctionValue.execute(FunctionValue.java:271) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.lambda$call$28(CarpetScriptHost.java:869) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.Expression.evalValue(Expression.java:1034) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.call(CarpetScriptHost.java:868) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.lambda$handleCommand$21(CarpetScriptHost.java:723) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.utils.GlocalFlag.whileValueReturn(GlocalFlag.java:44) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.utils.GlocalFlag.getWhileDisabled(GlocalFlag.java:30) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.handleCommand(CarpetScriptHost.java:723) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.execute(CarpetScriptHost.java:153) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at carpet.script.CarpetScriptHost.lambda$addPathToCommand$3(CarpetScriptHost.java:177) ~[fabric-carpet-1.19.4-1.4.101+v230319.jar:?]
        at com.mojang.brigadier.CommandDispatcher.execute(com/mojang/brigadier/CommandDispatcher.java:263) ~[brigadier-1.0.18.jar:?]
        at net.minecraft.class_2170.method_9249(net/minecraft/class_2170.java:285) ~[server-intermediary.jar:?]
        at net.minecraft.class_2170.method_44252(net/minecraft/class_2170.java:278) ~[server-intermediary.jar:?]
        at me.drex.votifier.VoteReceiver.run(VoteReceiver.java:121) ~[fabric-votifier-1.1.5.jar:?]
[08:29:49] [Thread-14/INFO]:  ... in _spawnWanderingTrader[conqvote]/27:28
[08:29:49] [Thread-14/INFO]:  ... in _runwithply[conqvote]/17:18
[08:29:49] [Thread-14/INFO]: Error while running custom command:    run(str('tellform %s <c:>[Votes]</c> <gray>Votre 6 vous a octroyé un Wandering Trader</gray>', ply, roll));
    HERE>> spawn('minecraft:wandering_trader', pos(player(ply)))
)
Internal error (please report this issue to Carpet) while evaluating: com.ishland.uwrad.common.CheckedThreadLocalRandom$1: ThreadLocalRandom accessed from a different thread (owner: Server thread, current: Thread-14)
Possible solutions: Find possible causes in the stack trace below and report to the corresponding mod authors 

 (You may make this a fatal warning instead of a hard crash with enforce_safe_world_random_access setting in uwrad.properties) in conqvote at line 29, pos 4
``
altrisi commented 1 year ago

Seems like it's not running on the server thread so it's getting multithreading issues.

As a workaround, running these functions in a scheduled call (schedule(0, ...)) is likely to fix it, as I'm quite sure schedules always run on the server thread.

Hellhium commented 1 year ago

Seems like it's not running on the server thread so it's getting multithreading issues.

As a workaround, running these functions in a scheduled call (schedule(0, ...)) is likely to fix it, as I'm quite sure schedules always run on the server thread.

Works fine thanks

gnembon commented 1 year ago

yeah, that's weird. I thought commands do run from the server thread. Maybe with so many mods they don't. schedule(0, is a hack to ensure this, but command should run from server thread, right?

altrisi commented 1 year ago

I believe this is an issue in Fabric-Votifier, from a quick look it seems to be running the vote received commands directly in their receiver thread instead of (as it's expected by the game and mods) in the server thread.

They do it here (assuming this is the one you're using): https://github.com/DrexHD/Fabric-Votifier/blob/6f9fd3928ad07a1abe752ae6ec05d8bc18733957/src/main/java/me/drex/votifier/VoteReceiver.java#L121

You should report it to them, this wouldn't be an issue with carpet once that's fixed.

James103 commented 1 year ago

The author of Fabric-Votifier has fixed this issue on their end; please update the mod on the server to version 1.1.6 or later for a proper fix.