Skip to content

fix: stop UDP xsgetn assembling after buffered residue#41

Merged
ruoka merged 1 commit into
masterfrom
cursor/critical-bug-management-4495
Jul 20, 2026
Merged

fix: stop UDP xsgetn assembling after buffered residue#41
ruoka merged 1 commit into
masterfrom
cursor/critical-bug-management-4495

Conversation

@cursor

@cursor cursor Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

After PR #37, endpointbuf::xsgetn still hung on a common UDP read pattern: wait_for() (or any peek) followed by read(buf, udp_buffer_size) for a short datagram. The call blocked forever waiting for more bytes, or could merge later datagrams.

Root cause

PR #37 only gated the count >= N bulk-recv path. endpointstream::wait_for peeks first, which underflows the short datagram into the get area. The following max-size read then drained that residue with count < N, skipped the gate, and entered the underflow assemble loop.

Fix

For SOCK_DGRAM, never cross datagram boundaries in xsgetn: return after draining buffered residue, and after a single underflow fill. TCP short-recv assembly is unchanged.

Validation

  • Added regression: "UDP max read after wait_for returns one datagram"
  • Ran NET_DISABLE_NETWORK_TESTS=0 tools/CB.sh debug test — both UDP xsgetn scenarios passed; remaining assertion failures are known cloud-fabric connect_with_timeout / environment noise unrelated to this change
Open in Web View Automation 

PR #37 gated only the count >= N bulk recv path. wait_for()/peek()
underflow a short datagram first, so a following read(udp_buffer_size)
drained residue with count < N and still assembled forever in the
underflow loop. Never cross datagram boundaries in xsgetn for SOCK_DGRAM.

Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.com>
@ruoka
ruoka marked this pull request as ready for review July 20, 2026 01:00
@ruoka
ruoka merged commit 877c5ed into master Jul 20, 2026
4 checks passed
@cursor

cursor Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@ruoka
ruoka deleted the cursor/critical-bug-management-4495 branch July 20, 2026 01:00
ruoka added a commit that referenced this pull request Jul 21, 2026
PR #37 gated only the count >= N bulk recv path. wait_for()/peek()
underflow a short datagram first, so a following read(udp_buffer_size)
drained residue with count < N and still assembled forever in the
underflow loop. Never cross datagram boundaries in xsgetn for SOCK_DGRAM.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.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.

2 participants