FastAsyncWorldEdit

FastAsyncWorldEdit

152k Downloads

Setting blocks causes IndexOutOfBoundsException

IAISI opened this issue ยท 2 comments

commented

Server Implementation

Paper

Server Version

1.20.4

Describe the bug

com.destroystokyo.paper.exception.ServerSchedulerException: Task #16224743 for FastAsyncWorldEdit v2.9.3-SNAPSHOT-755;debfabf generated an exception
	at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:497)
	at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1655)
	at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:452)
	at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1534)
	at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1234)
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:321)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IndexOutOfBoundsException: writerIndex(49520) + minWritableBytes(1) exceeds maxCapacity(49520): UnpooledHeapByteBuf(ridx: 0, widx: 49520, cap: 49520/49520)
	at io.netty.buffer.AbstractByteBuf.ensureWritable0(AbstractByteBuf.java:294)
	at io.netty.buffer.AbstractByteBuf.writeByte(AbstractByteBuf.java:984)
	at net.minecraft.network.VarInt.write(VarInt.java:58)
	at net.minecraft.network.FriendlyByteBuf.writeVarInt(FriendlyByteBuf.java:594)
	at net.minecraft.network.FriendlyByteBuf.writeLongArray(FriendlyByteBuf.java:418)
	at net.minecraft.world.level.chunk.PalettedContainer$Data.write(PalettedContainer.java:421)
	at net.minecraft.world.level.chunk.PalettedContainer.write(PalettedContainer.java:255)
	at net.minecraft.world.level.chunk.LevelChunkSection.write(LevelChunkSection.java:206)
	at net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData.extractChunkData(ClientboundLevelChunkPacketData.java:119)
	at net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData.<init>(ClientboundLevelChunkPacketData.java:55)
	at net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket.<init>(ClientboundLevelChunkWithLightPacket.java:36)
	at net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket.<init>(ClientboundLevelChunkWithLightPacket.java:30)
	at FastAsyncWorldEdit-Bukkit.jar//com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R3.PaperweightPlatformAdapter.lambda$sendChunk$5(PaperweightPlatformAdapter.java:362)
	at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftTask.run(CraftTask.java:101)
	at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:482)
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1655)
	at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:452)
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1534)
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1234)
	... 2 more

This might also be related:

[00:05:18] [Craft Scheduler Thread - 6875 - Plugin/ERROR]: [com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent] Catching
java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:?]
	at java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[?:?]
	at com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent.iterateSubmissions(SingleThreadQueueExtent.java:426) ~[FastAsyncWorldEdit-Bukkit.jar:?]
	at com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent.pollSubmissions(SingleThreadQueueExtent.java:374) ~[FastAsyncWorldEdit-Bukkit.jar:?]
	at com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent.flush(SingleThreadQueueExtent.java:472) ~[FastAsyncWorldEdit-Bukkit.jar:?]
	at com.fastasyncworldedit.core.queue.IQueueExtent.commit(IQueueExtent.java:103) ~[FastAsyncWorldEdit-Bukkit.jar:?]
	at com.fastasyncworldedit.core.extent.PassthroughExtent.commit(PassthroughExtent.java:221) ~[FastAsyncWorldEdit-Bukkit.jar:?]
	at com.fastasyncworldedit.core.extent.PassthroughExtent.commit(PassthroughExtent.java:221) ~[FastAsyncWorldEdit-Bukkit.jar:?]
	at com.sk89q.worldedit.EditSession.flushQueue(EditSession.java:1293) ~[FastAsyncWorldEdit-Bukkit.jar:?]
	at com.sk89q.worldedit.EditSession.close(EditSession.java:1233) ~[FastAsyncWorldEdit-Bukkit.jar:?]
	at net.plugin.features.GeneratorManager.lambda$run$0(GeneratorManager.java:200) ~[Plugin.jar:?]
	at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[sakura-1.20.4.jar:git-Sakura-"f948e10"]
	at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[sakura-1.20.4.jar:git-Sakura-"f948e10"]
	at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[sakura-1.20.4.jar:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
	at java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: java.lang.NullPointerException

GeneratorManager.java:200 would be: editSession.setBlock(blockX, blockY, blockZ, generator.getBlockType());

To Reproduce

At this point I'm unable to replicate, but it's caused by this code:

				plugin.getServer().getScheduler().runTaskAsynchronously(plugin, ()->
				{
					try (EditSession editSession = Fawe.instance().getWorldEdit().newEditSessionBuilder().world(BukkitAdapter.adapt(world)).fastMode(true).build()) {
						editSession.setBlock(blockX, blockY, blockZ, generator.getBlockType());
					} catch (Exception e) {
						e.printStackTrace();
					}
				});

players can spawn those tasks randomly and the issue would occur every now and then...

Expected behaviour

N/A

Screenshots / Videos

No response

Error log (if applicable)

No response

Fawe Debugpaste

https://athion.net/ISPaster/paste/view/f94b8329879c43a584e2bdc2b09ff5fc

Fawe Version

FastAsyncWorldEdit version 2.9.3-SNAPSHOT-755;debfabf

Checklist

Anything else?

No response

commented

You using a unsupported fork, please replicate it with paper

commented

Closing in favour of #2729