Skip to content

Fix silent truncation of UDP datagrams over 1024 bytes#499

Draft
IrPgFKS0 wants to merge 1 commit into
BeamMP:minorfrom
IrPgFKS0:fix/udp-datagram-truncation
Draft

Fix silent truncation of UDP datagrams over 1024 bytes#499
IrPgFKS0 wants to merge 1 commit into
BeamMP:minorfrom
IrPgFKS0:fix/udp-datagram-truncation

Conversation

@IrPgFKS0

@IrPgFKS0 IrPgFKS0 commented Jul 5, 2026

Copy link
Copy Markdown

Problem

TNetwork::UDPRcvFromClient receives into a fixed std::array<char, 1024>. UDP recvfrom() 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

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>
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