world.getLivingEntities() inside globalRegionScheduler.runAtFixedRate broken in dev/1.20.4 ? #184

Closed
opened 2024-01-22 18:37:45 +01:00 by Commandcracker · 5 comments
Commandcracker commented 2024-01-22 18:37:45 +01:00 (Migrated from github.com)

Expected behavior

No errors :D

Observed/Actual behavior

[21:43:41 ERROR]: Thread Region Scheduler Thread #0 failed main thread check: Accessing entity state off owning region's thread
java.lang.Throwable: null
        at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:78) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:25) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:10) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isInWorld(CraftEntity.java:939) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isValid(CraftEntity.java:393) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.lambda$getLivingEntities$2(CraftRegionAccessor.java:321) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
        at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.getLivingEntities(CraftRegionAccessor.java:317) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at com.palmergames.bukkit.towny.tasks.MobRemovalTimerTask.run(MobRemovalTimerTask.java:96) ~[towny-0.100.1.5.jar:?]
        at com.palmergames.bukkit.towny.scheduling.impl.FoliaTaskScheduler.lambda$runRepeating$6(FoliaTaskScheduler.java:87) ~[towny-0.100.1.5.jar:?]
        at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler$GlobalScheduledTask.run(FoliaGlobalRegionScheduler.java:179) ~[folia-1.20.4.jar:?]
        at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler.tick(FoliaGlobalRegionScheduler.java:37) ~[folia-1.20.4.jar:?]
        at io.papermc.paper.threadedregions.RegionizedServer.globalTick(RegionizedServer.java:293) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at io.papermc.paper.threadedregions.RegionizedServer$GlobalTickTickHandle.tickRegion(RegionizedServer.java:148) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at java.lang.Thread.run(Thread.java:840) ~[?:?]
[21:43:41 WARN]: [Towny] Global task for Towny v0.100.1.5 generated an exception
java.lang.IllegalStateException: Accessing entity state off owning region's thread
        at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:79) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:25) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:10) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isInWorld(CraftEntity.java:939) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isValid(CraftEntity.java:393) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.lambda$getLivingEntities$2(CraftRegionAccessor.java:321) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
        at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.getLivingEntities(CraftRegionAccessor.java:317) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at com.palmergames.bukkit.towny.tasks.MobRemovalTimerTask.run(MobRemovalTimerTask.java:96) ~[towny-0.100.1.5.jar:?]
        at com.palmergames.bukkit.towny.scheduling.impl.FoliaTaskScheduler.lambda$runRepeating$6(FoliaTaskScheduler.java:87) ~[towny-0.100.1.5.jar:?]
        at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler$GlobalScheduledTask.run(FoliaGlobalRegionScheduler.java:179) ~[folia-1.20.4.jar:?]
        at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler.tick(FoliaGlobalRegionScheduler.java:37) ~[folia-1.20.4.jar:?]
        at io.papermc.paper.threadedregions.RegionizedServer.globalTick(RegionizedServer.java:293) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at io.papermc.paper.threadedregions.RegionizedServer$GlobalTickTickHandle.tickRegion(RegionizedServer.java:148) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"4d78338"]
        at java.lang.Thread.run(Thread.java:840) ~[?:?]

Steps/models to reproduce

Use world.getLivingEntities() inside globalRegionScheduler.runAtFixedRate on dev/1.20.4

https://github.com/TownyAdvanced/Towny/issues/7202
MobRemovalTimerTask.java:96
FoliaTaskScheduler.java:87

Plugin and Datapack List

Towny 0.100.1.5

Folia version

This server is running Folia version git-Folia-"7bc26ec" (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 7bc26ec on dev/1.20.4)

Other

It works on 1.20.2.

### Expected behavior No errors :D ### Observed/Actual behavior ```log [21:43:41 ERROR]: Thread Region Scheduler Thread #0 failed main thread check: Accessing entity state off owning region's thread java.lang.Throwable: null at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:78) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:25) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:10) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isInWorld(CraftEntity.java:939) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isValid(CraftEntity.java:393) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.lambda$getLivingEntities$2(CraftRegionAccessor.java:321) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.getLivingEntities(CraftRegionAccessor.java:317) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at com.palmergames.bukkit.towny.tasks.MobRemovalTimerTask.run(MobRemovalTimerTask.java:96) ~[towny-0.100.1.5.jar:?] at com.palmergames.bukkit.towny.scheduling.impl.FoliaTaskScheduler.lambda$runRepeating$6(FoliaTaskScheduler.java:87) ~[towny-0.100.1.5.jar:?] at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler$GlobalScheduledTask.run(FoliaGlobalRegionScheduler.java:179) ~[folia-1.20.4.jar:?] at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler.tick(FoliaGlobalRegionScheduler.java:37) ~[folia-1.20.4.jar:?] at io.papermc.paper.threadedregions.RegionizedServer.globalTick(RegionizedServer.java:293) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at io.papermc.paper.threadedregions.RegionizedServer$GlobalTickTickHandle.tickRegion(RegionizedServer.java:148) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at java.lang.Thread.run(Thread.java:840) ~[?:?] [21:43:41 WARN]: [Towny] Global task for Towny v0.100.1.5 generated an exception java.lang.IllegalStateException: Accessing entity state off owning region's thread at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:79) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:25) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at org.bukkit.craftbukkit.v1_20_R3.entity.CraftBee.getHandle(CraftBee.java:10) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isInWorld(CraftEntity.java:939) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity.isValid(CraftEntity.java:393) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.lambda$getLivingEntities$2(CraftRegionAccessor.java:321) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] at org.bukkit.craftbukkit.v1_20_R3.CraftRegionAccessor.getLivingEntities(CraftRegionAccessor.java:317) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at com.palmergames.bukkit.towny.tasks.MobRemovalTimerTask.run(MobRemovalTimerTask.java:96) ~[towny-0.100.1.5.jar:?] at com.palmergames.bukkit.towny.scheduling.impl.FoliaTaskScheduler.lambda$runRepeating$6(FoliaTaskScheduler.java:87) ~[towny-0.100.1.5.jar:?] at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler$GlobalScheduledTask.run(FoliaGlobalRegionScheduler.java:179) ~[folia-1.20.4.jar:?] at io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler.tick(FoliaGlobalRegionScheduler.java:37) ~[folia-1.20.4.jar:?] at io.papermc.paper.threadedregions.RegionizedServer.globalTick(RegionizedServer.java:293) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at io.papermc.paper.threadedregions.RegionizedServer$GlobalTickTickHandle.tickRegion(RegionizedServer.java:148) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:404) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.20.4.jar:git-Folia-"4d78338"] at java.lang.Thread.run(Thread.java:840) ~[?:?] ``` ### Steps/models to reproduce Use `world.getLivingEntities()` inside `globalRegionScheduler.runAtFixedRate` on dev/1.20.4 https://github.com/TownyAdvanced/Towny/issues/7202 [MobRemovalTimerTask.java:96](https://github.com/TownyAdvanced/Towny/blob/13352a57769f05cbfb5c3c4655a8e0ded0e86b5e/Towny/src/main/java/com/palmergames/bukkit/towny/tasks/MobRemovalTimerTask.java#L96) [FoliaTaskScheduler.java:87](https://github.com/TownyAdvanced/Towny/blob/13352a57769f05cbfb5c3c4655a8e0ded0e86b5e/providers/FoliaProvider/src/main/java/com/palmergames/bukkit/towny/scheduling/impl/FoliaTaskScheduler.java#L87) ### Plugin and Datapack List Towny 0.100.1.5 ### Folia version This server is running Folia version git-Folia-"7bc26ec" (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 7bc26ec on dev/1.20.4) ### Other It works on 1.20.2.
MCFurina commented 2024-02-16 06:12:19 +01:00 (Migrated from github.com)

I'm running into this bug as well,It can be seen that this plugin has a bug on Folia 1.20.4

I'm running into this bug as well,It can be seen that this plugin has a bug on Folia 1.20.4
Spottedleaf commented 2024-02-21 01:30:39 +01:00 (Migrated from github.com)

Global region cannot access any region state, which includes entities.

Global region cannot access any region state, which includes entities.
LlmDl commented 2024-02-21 01:59:33 +01:00 (Migrated from github.com)

@Spottedleaf Towny has adapted already to the change so it's not a pressing matter any more. I am curious as to why it was working before the 1.20.4 versions. Did your team close a loophole?

@Spottedleaf Towny has adapted already to the change so it's not a pressing matter any more. I am curious as to why it was working before the 1.20.4 versions. Did your team close a loophole?
masmc05 commented 2024-02-21 10:16:56 +01:00 (Migrated from github.com)

Spottedleaf Towny has adapted already to the change so it's not a pressing matter any more. I am curious as to why it was working before the 1.20.4 versions. Did your team close a loophole?

more checks are added to protect the server from entering an unknown state, for which it needs to crash to escape safely without any data corruption

The more there are such checks, the less crashes caused by random plugin actions will happen

Edit: Or, in this case, spigot added new api which will require new checks

> Spottedleaf Towny has adapted already to the change so it's not a pressing matter any more. I am curious as to why it was working before the 1.20.4 versions. Did your team close a loophole? more checks are added to protect the server from entering an unknown state, for which it needs to crash to escape safely without any data corruption The more there are such checks, the less crashes caused by random plugin actions will happen Edit: Or, in this case, spigot added new api which will require new checks
electronicboy commented 2024-02-21 10:22:05 +01:00 (Migrated from github.com)
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/0478e0417b217d443d7ff8a52e3a97a1b7147d15#src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Fentity%2FCraftEntity.java?t=648
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Minecraft/Folia#184
No description provided.