A248 / LibertyBans

The be-all, end-all of discipline.
https://ci.hahota.net:8443/job/LibertyBans/
GNU Affero General Public License v3.0
169 stars 41 forks source link

[Bug Report]: DeadlockFreeFuture causes deadlock on Folia when trying to tab-complete #224

Closed kerudion closed 1 year ago

kerudion commented 1 year ago

LibertyBans Version

1.1.0-M3

I have confirmed that ...

Platform

Spigot/Paper

Description

After around 10 seconds after I try to get online players tab-completion on any of LibertyBans commands, I'm getting kicked with "Timed out" message. Then the server then is fully frozen: absolutely nothing works. Even console stops working. If I try to stop it with ctrl + c, server says [RegionShutdownThread] Awaiting scheduler termination for 60s and after exactly 60 seconds this error prints:

[16:02:17 WARN]: [RegionShutdownThread] Scheduler did not terminate within 60s, proceeding with shutdown anyways [16:02:17 WARN]: Region Scheduler Thread #0: Did not shut down in time [16:02:17 WARN]: at java.base@17.0.4.1/jdk.internal.misc.Unsafe.park(Native Method) [16:02:17 WARN]: at java.base@17.0.4.1/java.util.concurrent.locks.LockSupport.park(LockSupport.java:211) [16:02:17 WARN]: at java.base@17.0.4.1/java.util.concurrent.CompletableFuture$Signaller.block(CompletableFuture.java:1864) [16:02:17 WARN]: at java.base@17.0.4.1/java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3463) [16:02:17 WARN]: at java.base@17.0.4.1/java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3434) [16:02:17 WARN]: at java.base@17.0.4.1/java.util.concurrent.CompletableFuture.waitingGet(CompletableFuture.java:1898) [16:02:17 WARN]: at java.base@17.0.4.1/java.util.concurrent.CompletableFuture.join(CompletableFuture.java:2117) [16:02:17 WARN]: at LibertyBans-ClassLoader//space.arim.managedwaits.DeadlockFreeFuture.join(DeadlockFreeFuture.java:87) [16:02:17 WARN]: at LibertyBans-ClassLoader//space.arim.libertybans.env.spigot.SpigotCmdSender.getPlayerNames(SpigotCmdSender.java:61) [16:02:17 WARN]: at LibertyBans-ClassLoader//space.arim.libertybans.env.spigot.SpigotCmdSender.getPlayerNamesOnSameServer(SpigotCmdSender.java:66) [16:02:17 WARN]: at LibertyBans-ClassLoader//space.arim.libertybans.core.commands.extra.StandardTabCompletion.completeOnlinePlayerNames(StandardTabCompletion.java:101) [16:02:17 WARN]: at LibertyBans-ClassLoader//space.arim.libertybans.core.commands.extra.StandardTabCompletion.completeOfflinePlayerNames(StandardTabCompletion.java:109) [16:02:17 WARN]: at LibertyBans-ClassLoader//space.arim.libertybans.core.commands.PunishCommands.suggest(PunishCommands.java:90) [16:02:17 WARN]: at LibertyBans-ClassLoader//space.arim.libertybans.core.commands.CommandsCore.suggest(CommandsCore.java:147) [16:02:17 WARN]: at LibertyBans-ClassLoader//space.arim.libertybans.env.spigot.CommandHandler$CommandHelper.suggest(CommandHandler.java:92) [16:02:17 WARN]: at LibertyBans-ClassLoader//space.arim.libertybans.env.spigot.CommandHandler.suggest(CommandHandler.java:138) [16:02:17 WARN]: at LibertyBans-ClassLoader//space.arim.api.env.bukkit.BukkitCommandSkeleton.tabComplete(BukkitCommandSkeleton.java:85) [16:02:17 WARN]: at org.bukkit.command.Command.tabComplete(Command.java:93) [16:02:17 WARN]: at org.bukkit.command.SimpleCommandMap.tabComplete(SimpleCommandMap.java:240) [16:02:17 WARN]: at org.bukkit.craftbukkit.v1_20_R1.CraftServer.tabCompleteCommand(CraftServer.java:2400) [16:02:17 WARN]: at org.bukkit.craftbukkit.v1_20_R1.CraftServer.tabComplete(CraftServer.java:2372) [16:02:17 WARN]: at org.bukkit.craftbukkit.v1_20_R1.command.BukkitCommandWrapper.getSuggestions(BukkitCommandWrapper.java:74) [16:02:17 WARN]: at com.mojang.brigadier.tree.ArgumentCommandNode.listSuggestions(ArgumentCommandNode.java:71) [16:02:17 WARN]: at com.mojang.brigadier.CommandDispatcher.getCompletionSuggestions(CommandDispatcher.java:602)` [16:02:17 WARN]: at com.mojang.brigadier.CommandDispatcher.getCompletionSuggestions(CommandDispatcher.java:582) [16:02:17 WARN]: at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleCustomCommandSuggestions$3(ServerGamePacketListenerImpl.java:934) [16:02:17 WARN]: at net.minecraft.server.network.PlayerConnection$$Lambda$8526/0x0000000801da92c8.accept(Unknown Source) [16:02:17 WARN]: at io.papermc.paper.threadedregions.EntityScheduler.executeTick(EntityScheduler.java:173) [16:02:17 WARN]: at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1524) [16:02:17 WARN]: at io.papermc.paper.threadedregions.TickRegions$ConcreteRegionTickHandle.tickRegion(TickRegions.java:360) [16:02:17 WARN]: at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:385) [16:02:17 WARN]: at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) [16:02:17 WARN]: at java.base@17.0.4.1/java.lang.Thread.run(Thread.java:833)

A248 commented 1 year ago

A sure deadlock, now fixed. In the future, generating a thread dump (from the command-line or via a plugin like ThreadReport) is a great way to help developers solve the issue quickly. Here, the bug was simple enough.

You may find working development builds at https://ci.hahota.net:8443/