mojira.dev
MC-268727

Server disconnects the client when sending a keepalive packet while transitioning out of configuration phase

Hello, there is a tricky race condition in the latest snapshot, due to the server-side handling of `ServerboundFinishConfigurationPacket`. The packet is terminal, which causes the connection to become unbound immediately when it is received. It is then queued for processing on the main thread, which will eventually setup the outbound GAME protocol. In the meanwhile, it can happen that a keep alive packet is sent to the client, causing an immediate disconnection due to

Exception caught in connection
io.netty.handler.codec.EncoderException: Pipeline has no outbound protocol configured, can't process packet net.minecraft.network.protocol.common.ClientboundKeepAlivePacket@611a8815

For a more step-by-step explanation of the issue:

  • server receives ServerboundFinishConfigurationPacket on the netty thread and immediately disables its outbound protocol

  • netty thread calls handleConfigurationFinished, which enqueues itself for processing on the main thread

  • if unlucky: the main thread sends a ClientboundKeepAlivePacket

  • then the main executor would normally process handleConfigurationFinished and configure the protocol, but it's too late - the packet is already sent

The issue can be reproduced by adding the following code at the end of JoinWorldTask#start:

try {
    Thread.sleep(15000);
} catch (InterruptedException e) {
    throw new RuntimeException(e);
}

I have created a 24w07a Fabric mod that does exactly this, you can find it at https://github.com/Technici4n/MC-268727-repro.

Attachments

Comments 1

An attachment with a disallowed file extension has been removed from this ticket.

Executable files and documents are not allowed as attachments.
Please attach crash reports, log files and screenshots as they are instead of pasting them into a document.
-- I am a bot. This action was performed automatically! If you think it was incorrect, please notify us on Discord or Reddit

Technici4n

Timur Nazarov

Plausible

Platform

Important

Networking

24w07a

24w14a

Retrieved