Skip to content

Fix rare exception due to no function definition with multiple script loading threads#8563

Merged
UnderscoreTud merged 4 commits intodev/patchfrom
patch/function-loading-multiple-thread-loader
May 1, 2026
Merged

Fix rare exception due to no function definition with multiple script loading threads#8563
UnderscoreTud merged 4 commits intodev/patchfrom
patch/function-loading-multiple-thread-loader

Conversation

@Efnilite
Copy link
Copy Markdown
Member

Problem

In rare cases, reloading a script which used a function definition in a different script with multiple script loading threads would cause the function implementation to be undefined, which would cause an exception.

Solution

Instead of setting the function implementation to null, now marks the function implementation to be unloaded. The function reference will continue to use the old implementation until a new one can be found.

Testing Completed

Spam sk reload x with 1 worker thread in config.

Supporting Information


Completes: #8468
Related: none
AI assistance: none

@Efnilite Efnilite added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Apr 19, 2026
@Efnilite Efnilite requested a review from a team as a code owner April 19, 2026 21:23
@Efnilite Efnilite requested review from Pesekjak and TheMug06 and removed request for a team April 19, 2026 21:23
@skriptlang-automation skriptlang-automation Bot added the needs reviews A PR that needs additional reviews label Apr 19, 2026
Comment thread src/main/java/org/skriptlang/skript/common/function/FunctionReference.java Outdated
@Efnilite Efnilite requested a review from sovdeeth April 19, 2026 21:34
@TheLimeGlass
Copy link
Copy Markdown
Contributor

Caused by: java.lang.NullPointerException: Cannot invoke "org.skriptlang.skript.common.function.Function.execute(ch.njol.skript.lang.function.FunctionEvent, org.skriptlang.skript.common.function.FunctionArguments)" because "function" is null
[19:41:56 ERROR]: #!#!     at Skript-2.15.0.jar//org.skriptlang.skript.common.function.FunctionReference.execute(FunctionReference.java:185)
[19:41:56 ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.function.ExprFunctionCall.get(ExprFunctionCall.java:54)
[19:41:56 ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.util.SimpleExpression.getArray(SimpleExpression.java:86)
[19:41:56 ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.effects.EffChange.execute(EffChange.java:306)
[19:41:56 ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.Effect.run(Effect.java:42)
[19:41:56 ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:40)
[19:41:56 ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:67)
[19:41:56 ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.Trigger.execute(Trigger.java:33)
[19:41:56 ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.events.EvtPeriodical.execute(EvtPeriodical.java:103)
[19:41:56 ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.events.EvtPeriodical.lambda$postLoad$0(EvtPeriodical.java:62)
[19:41:56 ERROR]: #!#!     at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:78)
[19:41:56 ERROR]: #!#!     at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:474)
[19:41:56 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1657)
[19:41:56 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1527)
[19:41:56 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1249)
[19:41:56 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:308)
[19:41:56 ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:1583)

I still get errors with this

@TheLimeGlass
Copy link
Copy Markdown
Contributor

[19:59:36] [Server thread/ERROR]: #!#! Caused by: java.lang.NullPointerException: Cannot read the array length because "<local1>" is null
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.events.EvtPeriodical.unload(EvtPeriodical.java:80)
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.structures.StructEvent.unload(StructEvent.java:116)
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.ScriptLoader.unloadScripts(ScriptLoader.java:895)
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.ScriptLoader.unloadScript(ScriptLoader.java:934)
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.SkriptCommand.onCommand(SkriptCommand.java:188)
[19:59:36] [Server thread/ERROR]: #!#!     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[19:59:36] [Server thread/ERROR]: #!#!     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:158)
[19:59:36] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:1004)
[19:59:36] [Server thread/ERROR]: #!#!     at org.bukkit.Bukkit.dispatchCommand(Bukkit.java:1116)
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.Skript.dispatchCommand(Skript.java:1828)
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.effects.EffCommand.execute(EffCommand.java:82)
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.Effect.run(Effect.java:42)
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:40)
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:67)
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.Trigger.execute(Trigger.java:33)
[19:59:36] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.events.EvtScript.lambda$runTrigger$0(EvtScript.java:73)
[19:59:36] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:78)
[19:59:36] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:474)
[19:59:36] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1657)
[19:59:36] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1527)
[19:59:36] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1249)
[19:59:36] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:308)
[19:59:36] [Server thread/ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:1583)

This causes serious issues making it worse than the original bug

@TheLimeGlass
Copy link
Copy Markdown
Contributor

TheLimeGlass commented Apr 20, 2026

[20:03:44] [Server thread/ERROR]: #!#! Caused by: java.lang.NullPointerException: signature cannot be null
[20:03:44] [Server thread/ERROR]: #!#!     at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:922)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.function.FunctionRegistry.remove(FunctionRegistry.java:584)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.function.Functions.unregisterFunction(Functions.java:373)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.structures.StructFunction.unload(StructFunction.java:159)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.ScriptLoader.unloadScripts(ScriptLoader.java:895)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.ScriptLoader.unloadScript(ScriptLoader.java:934)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.SkriptCommand.onCommand(SkriptCommand.java:188)
[20:03:44] [Server thread/ERROR]: #!#!     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[20:03:44] [Server thread/ERROR]: #!#!     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:158)
[20:03:44] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:1004)
[20:03:44] [Server thread/ERROR]: #!#!     at org.bukkit.Bukkit.dispatchCommand(Bukkit.java:1116)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.Skript.dispatchCommand(Skript.java:1828)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.effects.EffCommand.execute(EffCommand.java:82)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.Effect.run(Effect.java:42)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:40)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:67)
[20:03:44] [Server thread/ERROR]: #!#!     at Skript-2.15.0.jar//ch.njol.skript.effects.Delay.lambda$walk$0(Delay.java:92)
[20:03:44] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:78)
[20:03:44] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:474)
[20:03:44] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1657)
[20:03:44] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1527)
[20:03:44] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1249)
[20:03:44] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:308)
[20:03:44] [Server thread/ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:1583)

Crashes the server

@TheLimeGlass
Copy link
Copy Markdown
Contributor

Original issues needs a priority bump

@sovdeeth
Copy link
Copy Markdown
Member

Can you post the log as a whole rather than just the stacktraces? it'll be helpful to see context around the errors.

@Efnilite
Copy link
Copy Markdown
Member Author

can you post the code you used to achieve this? im not seeing these errors

@github-project-automation github-project-automation Bot moved this from In Review to Awaiting Merge in 2.15 Releases May 1, 2026
@UnderscoreTud UnderscoreTud merged commit c9f6da5 into dev/patch May 1, 2026
13 checks passed
@github-project-automation github-project-automation Bot moved this from Awaiting Merge to Done - Awaiting Release in 2.15 Releases May 1, 2026
@TheLimeGlass
Copy link
Copy Markdown
Contributor

@sovdeeth @UnderscoreTud not fixed, it's even worse now. See original issue.

@APickledWalrus APickledWalrus moved this from Done - Awaiting Release to Done - Released in 2.15 Releases May 5, 2026
@APickledWalrus APickledWalrus deleted the patch/function-loading-multiple-thread-loader branch May 5, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. needs reviews A PR that needs additional reviews

Projects

Status: Done - Released

Development

Successfully merging this pull request may close these issues.

5 participants