Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server crash on player disconnect (something in PlayerQuitEvent) #219

Open
gummianka opened this issue Apr 28, 2024 · 3 comments
Open

Server crash on player disconnect (something in PlayerQuitEvent) #219

gummianka opened this issue Apr 28, 2024 · 3 comments
Labels

Comments

@gummianka
Copy link

Stack trace

[10:30:13 INFO]: gummi_anka lost connection: Disconnected
[10:30:13 ERROR]: Thread Region Scheduler Thread #0 failed main thread check: Cannot remove entity off-main
java.lang.Throwable: null
  at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:78) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.world.entity.Entity.setRemoved(Entity.java:5602) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.world.entity.Entity.remove(Entity.java:708) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.world.entity.LivingEntity.remove(LivingEntity.java:783) ~[?:?]
  at net.minecraft.world.entity.player.Player.remove(Player.java:1522) ~[?:?]
  at net.minecraft.server.level.ServerLevel.removePlayerImmediately(ServerLevel.java:1932) ~[?:?]
  at net.minecraft.server.players.PlayerList.remove(PlayerList.java:757) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.server.players.PlayerList.remove(PlayerList.java:696) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.server.network.ServerGamePacketListenerImpl.removePlayerFromWorld(ServerGamePacketListenerImpl.java:2143) ~[?:?]
  at net.minecraft.server.network.ServerGamePacketListenerImpl.onDisconnect(ServerGamePacketListenerImpl.java:2121) ~[?:?]
  at net.minecraft.server.network.ServerGamePacketListenerImpl.onDisconnect(ServerGamePacketListenerImpl.java:2108) ~[?:?]
  at net.minecraft.network.Connection.handleDisconnection(Connection.java:894) ~[?:?]
  at io.papermc.paper.threadedregions.RegionizedWorldData.tickConnections(RegionizedWorldData.java:516) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1843) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:447) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1657) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at io.papermc.paper.threadedregions.TickRegions$ConcreteRegionTickHandle.tickRegion(TickRegions.java:407) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at java.lang.Thread.run(Thread.java:1583) ~[?:?]
[10:30:13 ERROR]: [io.papermc.paper.threadedregions.TickRegionScheduler] Region #1 centered at chunk [41, 53] in world 'arena' failed to tick:
java.lang.IllegalStateException: Cannot remove entity off-main
  at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:79) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.world.entity.Entity.setRemoved(Entity.java:5602) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.world.entity.Entity.remove(Entity.java:708) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.world.entity.LivingEntity.remove(LivingEntity.java:783) ~[?:?]
  at net.minecraft.world.entity.player.Player.remove(Player.java:1522) ~[?:?]
  at net.minecraft.server.level.ServerLevel.removePlayerImmediately(ServerLevel.java:1932) ~[?:?]
  at net.minecraft.server.players.PlayerList.remove(PlayerList.java:757) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.server.players.PlayerList.remove(PlayerList.java:696) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.server.network.ServerGamePacketListenerImpl.removePlayerFromWorld(ServerGamePacketListenerImpl.java:2143) ~[?:?]
  at net.minecraft.server.network.ServerGamePacketListenerImpl.onDisconnect(ServerGamePacketListenerImpl.java:2121) ~[?:?]
  at net.minecraft.server.network.ServerGamePacketListenerImpl.onDisconnect(ServerGamePacketListenerImpl.java:2108) ~[?:?]
  at net.minecraft.network.Connection.handleDisconnection(Connection.java:894) ~[?:?]
  at io.papermc.paper.threadedregions.RegionizedWorldData.tickConnections(RegionizedWorldData.java:516) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1843) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:447) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1657) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at io.papermc.paper.threadedregions.TickRegions$ConcreteRegionTickHandle.tickRegion(TickRegions.java:407) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"2986554"]
  at java.lang.Thread.run(Thread.java:1583) ~[?:?]

Plugin and Datapack List

MyOwnPlugin, GrimAC, Chunky, ProtocolLib, ViaBackwards, ViaVersion, WorldEdit, spark

Actions to reproduce (if known)

I have my own duels minigame plugin, when a player leaves from a duel (disconnect, command) I call:

player.teleportAsync(loc)
player.getInventory().clear();
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20);
player.setHealth(20);
player.setFoodLevel(20);
player.setSaturation(0);
player.setExhaustion(0);
player.setFireTicks(0);

for (PotionEffect effect : player.getActivePotionEffects()) {
    player.removePotionEffect(effect.getType());
}

On paper it was fine to do this on PlayerQuitEvent, I have disabled calling these methods and the server stopped crashing on player disconnect.

Folia version

git-Folia-"2986554" (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 2986554)

Other

I patched folia myself for some changes for my server, but also on "clear" folia with last commit 25ee657 I can reproduce same issue

@electronicboy
Copy link
Member

We cannot accept stack traces from software that isn't ours

@gummianka
Copy link
Author

I tried to reproduce this issue on full empty server, only with plugin with PlayerQuitEvent, tried to teleport player to different worlds, but there is no crash.

But I can still reproduce this crash with my plugins on clear folia. This stack traces doesnt contains my methods, that is why I created this issue

This server is running Folia version git-Folia-"25ee657" (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 25ee657)\nYou are running the latest version

[14:34:00] [Region Scheduler Thread #1/INFO]: gummi_anka lost connection: Disconnected
[14:34:00] [Region Scheduler Thread #1/ERROR]: Thread Region Scheduler Thread #1 failed main thread check: Cannot remove entity off-main
java.lang.Throwable: null
	at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:78) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.world.entity.Entity.setRemoved(Entity.java:5588) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.world.entity.Entity.remove(Entity.java:708) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.world.entity.LivingEntity.remove(LivingEntity.java:783) ~[?:?]
	at net.minecraft.world.entity.player.Player.remove(Player.java:1522) ~[?:?]
	at net.minecraft.server.level.ServerLevel.removePlayerImmediately(ServerLevel.java:1932) ~[?:?]
	at net.minecraft.server.players.PlayerList.remove(PlayerList.java:757) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.server.players.PlayerList.remove(PlayerList.java:696) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.removePlayerFromWorld(ServerGamePacketListenerImpl.java:2143) ~[?:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.onDisconnect(ServerGamePacketListenerImpl.java:2121) ~[?:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.onDisconnect(ServerGamePacketListenerImpl.java:2108) ~[?:?]
	at net.minecraft.network.Connection.handleDisconnection(Connection.java:894) ~[?:?]
	at io.papermc.paper.threadedregions.RegionizedWorldData.tickConnections(RegionizedWorldData.java:516) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1843) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:447) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1657) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at io.papermc.paper.threadedregions.TickRegions$ConcreteRegionTickHandle.tickRegion(TickRegions.java:407) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at java.lang.Thread.run(Thread.java:1583) ~[?:?]
[14:34:00] [Region Scheduler Thread #1/ERROR]: [io.papermc.paper.threadedregions.TickRegionScheduler] Region #1 centered at chunk [41, 53] in world 'arena' failed to tick:
java.lang.IllegalStateException: Cannot remove entity off-main
	at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:79) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.world.entity.Entity.setRemoved(Entity.java:5588) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.world.entity.Entity.remove(Entity.java:708) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.world.entity.LivingEntity.remove(LivingEntity.java:783) ~[?:?]
	at net.minecraft.world.entity.player.Player.remove(Player.java:1522) ~[?:?]
	at net.minecraft.server.level.ServerLevel.removePlayerImmediately(ServerLevel.java:1932) ~[?:?]
	at net.minecraft.server.players.PlayerList.remove(PlayerList.java:757) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.server.players.PlayerList.remove(PlayerList.java:696) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.removePlayerFromWorld(ServerGamePacketListenerImpl.java:2143) ~[?:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.onDisconnect(ServerGamePacketListenerImpl.java:2121) ~[?:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.onDisconnect(ServerGamePacketListenerImpl.java:2108) ~[?:?]
	at net.minecraft.network.Connection.handleDisconnection(Connection.java:894) ~[?:?]
	at io.papermc.paper.threadedregions.RegionizedWorldData.tickConnections(RegionizedWorldData.java:516) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1843) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:447) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1657) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at io.papermc.paper.threadedregions.TickRegions$ConcreteRegionTickHandle.tickRegion(TickRegions.java:407) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"25ee657"]
	at java.lang.Thread.run(Thread.java:1583) ~[?:?]
[14:34:00] [Region shutdown thread/INFO]: [RegionShutdownThread] Awaiting scheduler termination for 60s
[14:34:00] [Region shutdown thread/INFO]: [RegionShutdownThread] Scheduler halted
[14:34:00] [Region shutdown thread/INFO]: Stopping server

@PedroMPagani
Copy link

player.teleportAsync(loc)
player.getInventory().clear();
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20);
player.setHealth(20);
player.setFoodLevel(20);
player.setSaturation(0);
player.setExhaustion(0);
player.setFireTicks(0);

for (PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}

these actions on a player quit are kind of "dumb", you should schedule those actions for the new player join event instead

@kashike kashike added the version: 1.20.4 Game version 1.20.4 label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants
@electronicboy @kashike @gummianka @PedroMPagani and others