Repository navigation
UDP: receive datagrams up to the IPv4 maximum, a datagram over 2000 bytes ended all capture - #427
Merged
janwilmans merged 1 commit intoNov 4, 2026
Conversation
…2000-byte buffer ended all capture The UDP source received into a 2000-byte buffer. A larger datagram fails the receive with WSAEMSGSIZE, that exception is rethrown on the thread that reads all sources, an "Exception occurred" box is shown, and the program ends when it is closed. Log frameworks send larger datagrams routinely, log4net's UdpAppender sends an exception with its stack trace as a single datagram, so DebugView++ could not be used as a UDP log viewer. The buffer is now 65536 bytes, room for the largest UDP datagram over IPv4 (65507 bytes), so the receive can no longer fail this way. LogSourceUdpReaderReceivesLargeDatagrams sends datagrams of 100, 2000, 2001, 10000 and 65507 bytes to a UDP reader and expects all of them. With the old buffer it receives only the first two. Co-Authored-By: Claude Opus 5.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.
A UDP datagram larger than 2000 bytes crashes DebugView++.
What happens.
SocketReaderreceives into astd::array<char, 2000>. A larger datagram fails the receive withWSAEMSGSIZE, andWSAGetOverlappedResultthrows.LogSources::Listenrethrows on the thread that reads every source, so an "Exception occurred" box appears. The text is "A message sent on a datagram socket was larger than the internal message buffer...", fromLogSources.cpp:221. When the box is closed the program ends, so all capture stops, not only UDP.Why it matters. Logging frameworks send large datagrams routinely: log4net's
UdpAppender, for example, sends an exception with its stack trace as a single datagram. On one development machine of ours, 298 of 86,723 logged messages were over 2000 bytes (the largest 63,846), and most days' logs had at least one. That makes the UDP source unusable as a log viewer.Fix. The buffer is now 65536 bytes. That holds the largest UDP payload over IPv4 (65,507 bytes), and the socket is
AF_INET, so the receive can no longer fail this way.SocketReaderis created withmake_uniqueinLogSources::AddUDPReader, so the larger member is on the heap.Test.
LogSourceUdpReaderReceivesLargeDatagramssends datagrams of 100, 2000, 2001, 10,000 and 65,507 bytes to a UDP reader on port 2035, one at a time, and expects to receive all five.Checked, with VS 18 (MSVC 14.51), Release x64:
{ 100, 2000 }and nothing after.ctest -C Releasepasses, with the sameGTEST_FILTERas CI.Debugviewpp.exe, listening on a UDP port, received messages of 1999, 2000, 2001, 2500, 9000 and 63,846 bytes, and kept receiving afterwards, with no exception box.🤖 Generated with Claude Code