Refined Storage

Refined Storage

77M Downloads

Crash with too many advancements

Darkhax opened this issue ยท 6 comments

commented

Issue description:

Once too many advancements are unlocked, the player will be unable to join a server. In every instance we have reproduced this, it was with an RS advancement.

What happens:

The client is disconnected and can not reconnect.

What you expected to happen:

Advancements to not force disconnect the player, and for everyone to have a good time.

Steps to reproduce:

  1. Download RS and other mods.
  2. Unlock a lot of advancements.
  3. Disconnect and be sad :/
    ...

Version (make sure you are on the latest version before reporting):

  • Minecraft: 1.12
  • Forge: 14.21.1.2396
  • Refined Storage: 1.5.7

Does this issue occur on a server? [yes/no]
Yep

If a (crash)log is relevant for this issue, link it here:

[00:31:42] [Netty Client IO #0/ERROR] [FML]: NetworkDispatcher exception
io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(62855) + length(1) exceeds writerIndex(62855): UnpooledHeapByteBuf(ridx: 62855, widx: 62855, cap: 62855/62855)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:442) ~[netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248) ~[netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:280) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:396) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:287) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:624) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:559) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:476) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [netty-all-4.1.9.Final.jar:4.1.9.Final]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
Caused by: java.lang.IndexOutOfBoundsException: readerIndex(62855) + length(1) exceeds writerIndex(62855): UnpooledHeapByteBuf(ridx: 62855, widx: 62855, cap: 62855/62855)
	at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1396) ~[netty-all-4.1.9.Final.jar:4.1.9.Final]
	at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:687) ~[netty-all-4.1.9.Final.jar:4.1.9.Final]
	at net.minecraft.network.PacketBuffer.readByte(PacketBuffer.java:864) ~[gy.class:?]
	at net.minecraft.network.PacketBuffer.func_150793_b(PacketBuffer.java:303) ~[gy.class:?]
	at net.minecraft.network.PacketBuffer.func_150791_c(PacketBuffer.java:361) ~[gy.class:?]
	at net.minecraft.advancements.DisplayInfo.func_192295_b(SourceFile:135) ~[r.class:?]
	at net.minecraft.advancements.Advancement$Builder.func_192060_b(SourceFile:251) ~[i$a.class:?]
	at net.minecraft.network.play.server.SPacketAdvancementInfo.func_148837_a(SourceFile:51) ~[kt.class:?]
	at net.minecraft.network.NettyPacketDecoder.decode(SourceFile:40) ~[gz.class:?]
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411) ~[netty-all-4.1.9.Final.jar:4.1.9.Final]
	... 35 more
commented

I tracked this down to just one advancement.
/advancement grant mezz only refinedstorage:storing_fluids will cause me to disconnect from a server.
I'm not sure why it happens yet, but that should narrow things down a lot.

commented
commented

The server logs this, without a stacktrace, when writing the advancement packet if it contains "refinedstorage:storing_fluids":

[21:16:09] [Netty Server IO #2/ERROR] [net.minecraft.network.NettyPacketEncoder]: java.lang.NullPointerException

After tracing through the packet serialization I got the source of the the NPE:

at com.raoulvdberge.refinedstorage.apiimpl.storage.StorageDiskFluid.getStored(StorageDiskFluid.java:241)
at com.raoulvdberge.refinedstorage.apiimpl.storage.StorageDiskFluid.getShareTag(StorageDiskFluid.java:233)
at com.raoulvdberge.refinedstorage.apiimpl.storage.StorageDiskBehavior.getShareTag(StorageDiskBehavior.java:27)
at com.raoulvdberge.refinedstorage.item.ItemFluidStorageDisk.getNBTShareTag(ItemFluidStorageDisk.java:133)
at net.minecraft.network.PacketBuffer.writeItemStack(PacketBuffer.java:371)
at net.minecraft.advancements.DisplayInfo.write(DisplayInfo.java:143)
at net.minecraft.advancements.Advancement$Builder.writeTo(Advancement.java:217)
at net.minecraft.network.play.server.SPacketAdvancementInfo.writePacketData(SPacketAdvancementInfo.java:100)
at net.minecraft.network.NettyPacketEncoder.encode(NettyPacketEncoder.java:51)
at net.minecraft.network.NettyPacketEncoder.encode(NettyPacketEncoder.java:12)
at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730)
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816)
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723)
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.write(NetworkDispatcher.java:542)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738)
at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:801)
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:814)
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:794)
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:831)
at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1032)
at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:296)
at net.minecraft.network.NetworkManager$4.run(NetworkManager.java:261)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
at java.lang.Thread.run(Thread.java:745)

The "fluid_storage_disk" item stack used for the advancement's display icon has no nbt so StorageDiskFluid#getStored fails.

commented

seems like the fix is to get MinecraftForge/MinecraftForge#4114 merged?

commented

Aha, didn't expect that. RS only needs the stored tag for tooltip rendering, completely forgot about the NBT share tag.

commented

Well, I could add a workaround in the share tag code. Will do that.