Skip to content

minecraft/conn.go: replay RequestChunkRadius received before StartGame - #462

Open
RestartFU wants to merge 1 commit into
Sandertv:masterfrom
RestartFU:upstream/early-request-chunk-radius
Open

minecraft/conn.go: replay RequestChunkRadius received before StartGame#462
RestartFU wants to merge 1 commit into
Sandertv:masterfrom
RestartFU:upstream/early-request-chunk-radius

Conversation

@RestartFU

Copy link
Copy Markdown
Contributor

A client that sends RequestChunkRadius after the login sequence completes but before StartGame() is called has the packet routed to the user read queue, so handleRequestChunkRadius never runs. The client then waits forever for ChunkRadiusUpdated, never sends SetLocalPlayerAsInitialised, and StartGame blocks indefinitely — a deadlock with no timeout on either side.

In a plain server this window is microseconds, but on proxies (which read packets from the accepted connection while dialing the downstream server) it spans the whole downstream dial + handshake, and some clients (observed with Android/console timing) send RequestChunkRadius early enough to hit it.

Fix: stash such a packet and replay it through handle() right after startGame(), which expects IDRequestChunkRadius at that point. The packet is still delivered to the user read queue, so proxies that forward it downstream see no behavior change; servers that call StartGame immediately are unaffected (the stash stays nil).

A client that sends RequestChunkRadius after login completes but before
StartGame() is called has the packet routed to the user read queue, so
handleRequestChunkRadius never runs. The client then waits forever for
ChunkRadiusUpdated and never sends SetLocalPlayerAsInitialised, leaving
StartGame blocked. On a proxy the window between login and StartGame spans
the downstream dial + handshake, making this easy to hit under load.

Stash such a packet and replay it through handle() right after startGame(),
which expects IDRequestChunkRadius at that point. The packet is still
delivered to the user so proxies keep forwarding it downstream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant