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

IndexOutOfBoundsException in PacketEvents while using Matrix #1029

Open
thisisaef opened this issue Oct 19, 2024 · 6 comments
Open

IndexOutOfBoundsException in PacketEvents while using Matrix #1029

thisisaef opened this issue Oct 19, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@thisisaef
Copy link

thisisaef commented Oct 19, 2024

Describe the bug
When executing the /ecoenchants gui command and I select the special enchantment book, I get kicked off the server when clicking the special enchantment book. Matrix throws an IndexOutOfBoundsException related to packet handling, which seems to occur when handling the window event when clicking the enchantment book, causing the Netty buffer to crash during the processing of the item data.

Software brand
Paper version 1.21.1-120-master@57c75a4

Velocity Version
Velocity 3.3.0-SNAPSHOT (git-2016d148-b436)

Plugins
Spark profile#1: https://spark.lucko.me/bDBUBmexU8
#1 packetevents (v2.5.0)
Spark profile#2: https://spark.lucko.me/cur98ZyVSd
#2 packetevents (v2.5.1+e13632774-SNAPSHOT)

How To Reproduce
Steps to reproduce the behavior:

  1. Install the Matrix plugin alongside EcoEnchants.
  2. Execute the /ecoenchants gui command.
  3. When selecting the special enchantment book in the GUI window,
  4. Observe the server logs for the IndexOutOfBoundsException error.

Expected behavior
The plugin should open /ecoenchants gui and use the special enchantment book without crashing or throwing any exceptions, allowing the game to run smoothly.

Actual Behavior
The server throws IndexOutOfBoundsException and logs an error stack trace when trying to read from the packet buffer, resulting in the inability to use the special enchantment book in the EcoEnchants GUI window properly.

Screenshots
https://github.com/user-attachments/assets/fcc23773-7901-4c25-adfd-f351e51d3674

Additional context
It seems to be a problem when Matrix interacts with packets related to the interaction of items in EcoEnchants custom configuration integration. I have tested with Matrix developer, he helped me fully with the Matrix protection plugin. He said that this has a problem with packetevents-spigot-2.5.0 & packetevents-velocity-2.5.0, you guys who developed packetevents need to help fix this.

@thisisaef thisisaef added the bug Something isn't working label Oct 19, 2024
@thisisaef
Copy link
Author

thisisaef commented Oct 19, 2024

When I bounce out of this issue, I get a notification in the chat box like this:

image

@thisisaef
Copy link
Author

thisisaef commented Oct 19, 2024

report the bug to packetevents
Matrix is using packetevents 2.5.1 snapshot
bug error: https://paste.helpch.at/ledoyeveyi.css

@booky10
Copy link
Collaborator

booky10 commented Oct 21, 2024

I can't reproduce this issue using the latest packetevents build and latest ecoenchants version
I can't test this using Matrix, as Matrix is not available for free and also closed-source

2024-10-21.17-41-04.mp4

Are you running the latest Matrix version and does Matrix use the latest packetevents build?

@thisisaef
Copy link
Author

thisisaef commented Oct 23, 2024

Dev Matrix:
image
I'm use
image
and PacketEvent
image

@re-ovo
Copy link

re-ovo commented Oct 24, 2024

I'm the author of Matrix and I'm using implementation("com.github.retrooper:packetevents-spigot:2.5.1-SNAPSHOT")

Here's the stacktrace of error:

[13:26:47] [Netty Server IO #1/WARN]: [me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.PacketEventsAPI] PacketEvents caught an unhandled exception while calling your listener.
java.lang.IndexOutOfBoundsException: readerIndex(18) + length(1) exceeds writerIndex(18): PooledUnsafeDirectByteBuf(ridx: 18, widx: 18, cap: 18)
	at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1442) ~[netty-buffer-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.buffer.AbstractByteBuf.readByte(AbstractByteBuf.java:730) ~[netty-buffer-4.1.97.Final.jar:4.1.97.Final]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.io.github.retrooper.packetevents.netty.buffer.ByteBufOperatorModernImpl.readByte(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.netty.buffer.ByteBufHelper.readByte(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.PacketWrapper.readByte(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.PacketWrapper.readVarInt(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.PacketWrapper.readMappedEntity(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.PacketWrapper.readMappedEntity(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEnchantments.lambda$read$0(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.PacketWrapper.readMap(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.protocol.component.builtin.item.ItemEnchantments.read(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.protocol.component.StaticComponentType.read(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.PacketWrapper.readItemStackModern(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.PacketWrapper.readItemStack(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow.read(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.PacketWrapper.readEvent(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.PacketWrapper.<init>(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.PacketWrapper.<init>(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow.<init>(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix._.qa.u(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix._.wk.onPacketReceive(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.event.PacketReceiveEvent.call(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.event.EventManager.callEvent(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.com.github.retrooper.packetevents.util.PacketEventsImplHelper.handleServerBoundPacket(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.io.github.retrooper.packetevents.injector.handlers.PacketEventsDecoder.read(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.io.github.retrooper.packetevents.injector.handlers.PacketEventsDecoder.decode(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at Matrix_7.11.5.jar/me.rerere.matrix.thirdparty.io.github.retrooper.packetevents.injector.handlers.PacketEventsDecoder.decode(Unknown Source) ~[Matrix_7.11.5.jar:?]
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at ProtocolLib.jar/com.comphenix.protocol.injector.netty.channel.InboundProtocolReader.channelRead(InboundProtocolReader.java:25) ~[ProtocolLib.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.handler.flow.FlowControlHandler.dequeue(FlowControlHandler.java:202) ~[netty-handler-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.handler.flow.FlowControlHandler.channelRead(FlowControlHandler.java:164) ~[netty-handler-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) ~[netty-handler-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.handler.flush.FlushConsolidationHandler.channelRead(FlushConsolidationHandler.java:152) ~[netty-handler-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
	at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
[13:26:47] [Server thread/INFO]: z1ncq lost connection: Internal Exception: io.netty.handler.codec.DecoderException: Failed to decode packet 'serverbound/minecraft:container_click'

image

@mitchellonii
Copy link

also experiencing this error with custom model data jukebox discs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants