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

PlayerKickEvent triggered on wrong thread #7362

Closed
brawaru opened this issue Jan 17, 2022 · 1 comment · Fixed by #7363
Closed

PlayerKickEvent triggered on wrong thread #7362

brawaru opened this issue Jan 17, 2022 · 1 comment · Fixed by #7363
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.18 Game version 1.18

Comments

@brawaru
Copy link

brawaru commented Jan 17, 2022

Expected behavior

Bedrock Edition players can enter some characters that are considered illegal on Java Editions, so whenever player sends such characters they are supposed to be disconnected with reason multiplayer.disconnect.illegal_characters.

Observed/Actual behavior

Paper specifies the cause for disconnect — a kick. This causes it to try and fire PlayerKickEvent, however, it can only be triggered on the main thread, while the chat is handled on a separate thread, which results in an IllegalStateException. This still disconnects the player but does not show them a meaningful message, instead, they see ‘Internal Exception: java.lang.IllegalStateException: PlayerKickEvent may only be triggered synchronously.’

Steps/models to reproduce

The easiest way is to install Geyser and Floodgate plugin, then to connect to the server using Bedrock Edition and simply send § paragraph character, which is illegal on Java.

Plugin and Datapack List

Plugins (3): floodgate, Geyser-Spigot, ProtocolLib

Paper version

[19:25:52 INFO]: Checking version, please wait...
[19:25:53 INFO]: This server is running Paper version git-Paper-155 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) (Git: 99cf01f)
You are running the latest version

Other

Related LOC: Paper-Server/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java:2070

Debug stack trace
[17:42:26 DEBUG]: Failed to sent packet
java.lang.IllegalStateException: PlayerKickEvent may only be triggered synchronously.
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:616) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.disconnect(ServerGamePacketListenerImpl.java:446) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.disconnect(ServerGamePacketListenerImpl.java:432) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2070) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundChatPacket.a(ServerboundChatPacket.java:6) ~[?:?]
        at net.minecraft.network.Connection.genericsFtw(Connection.java:281) ~[?:?]
        at net.minecraft.network.Connection.channelRead0(Connection.java:267) ~[?:?]
        at net.minecraft.network.Connection.channelRead0(Connection.java:54) ~[?:?]
        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:302) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at com.comphenix.protocol.injector.netty.ChannelInjector$2.channelRead(ChannelInjector.java:289) ~[ProtocolLib.jar:?]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.handler.flush.FlushConsolidationHandler.channelRead(FlushConsolidationHandler.java:152) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.local.LocalChannel.readInbound(LocalChannel.java:299) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.local.LocalChannel.finishPeerRead0(LocalChannel.java:445) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.local.LocalChannel.access$400(LocalChannel.java:50) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.local.LocalChannel$5.run(LocalChannel.java:403) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-all-4.1.68.Final.jar:4.1.68.Final]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
@brawaru brawaru added status: needs triage type: bug Something doesn't work as it was intended to. labels Jan 17, 2022
@molor
Copy link

molor commented Jan 17, 2022

The easiest way iirc is send Component to player that inserts command with a section sign (e.g. /§4test) into chat on click and then press [Enter]/send it. I don't know, maybe this cause has been fixed, but I encountered it in the early versions of Paper 1.18 during chat plugin testing :p

@lynxplay lynxplay added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. version: 1.18 Game version 1.18 and removed status: needs triage labels Jan 17, 2022
Camotoy added a commit to GeyserMC/Geyser that referenced this issue Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.18 Game version 1.18
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants