Fix silent truncation of UDP datagrams over 1024 bytes#499
Draft
IrPgFKS0 wants to merge 1 commit into
Draft
Conversation
recvfrom() into a 1 KB buffer clips any larger datagram and the tail is lost. A compressed position packet from a client with several moving vehicles exceeds that, so those updates were silently dropped and the remote vehicles stuttered/warped. Size the receive buffer to the UDP maximum instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TNetwork::UDPRcvFromClientreceives into a fixedstd::array<char, 1024>. UDPrecvfrom()truncates any datagram larger than the buffer — the tail is silently lost. A compressed (ABG:) position packet from a client with several moving vehicles can exceed 1 KB, so those updates were silently dropped (the truncated payload fails to decompress/parse), and other players saw those vehicles stutter or warp.Fix
Size the receive buffer to the UDP maximum (65535). One-line change plus a comment; the function already returns only the received byte count, so there is no behavior change for small datagrams.
How this was found
Diagnosed while profiling remote-vehicle drift on a LAN fork of BeamMP (position updates from multi-vehicle clients disappearing under load); the fix has been running in that fork for weeks of sessions.
Transparency
This fix comes from an AI-assisted fork: the bug was found and the patch written with the help of an AI coding tool (Claude), then tested by a human in real multiplayer sessions. Given this project's policy on AI-generated code, it's submitted as a draft for the maintainers to decide — happy to close it if that's not wanted, or for a maintainer to re-implement the one-liner independently.
🤖 Generated with Claude Code