UCP/WIREUP: Fix pending count when wireup send fails the EP #12394
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 196 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.316
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #12394"
general
weight: 0.35
tvegas1
What?
Fix
Assertion 'wireup_ep->pending_count == 0' failedinucp_wireup_ep_pending_purge(), and a use-after-free of the wireup EP, when sending a pending wireup message fails the UCP EP.Why?
A wireup message queued on a wireup EP is wrapped in a proxy request and added to the pending queue of the UCT EP.
wireup_ep->pending_countcounts these requests, so that the purge knows to purge the UCT queue.UCT removes the proxy request from its queue before calling
ucp_wireup_ep_progress_pending(), but the counter was decremented only after the send. TCP reports a send error by calling the iface error handler from insideuct_ep_am_bcopy(). The UCP EP is then failed and its lanes are discarded. The purge does not find the request on the UCT queue, so the count stays 1 and the assertion fails. Without assertions, the wireup EP is destroyed during the send, and the decrement then writes to freed memory (confirmed with valgrind).Seen in CI on
tcp/test_ucp_wireup_errh_peer.force_close_simultaneous_connect_winner/0: in a simultaneous connect, TCP adopts the socket of the force-closed EP, and the pending wireup request fails with a broken pipe.How?
ucp_wireup_ep_progress_pending(): decrementpending_countbefore sending, and increment it back if the request goes back to the pending queue.test_ucp_wireup_errh_peer.pending_wireup_msg_send_error: on tcp, fail the send of the pending wireup request from insideuct_ep_am_bcopy(), as tcp does. Without the fix it hits the assertion on all tcp variants.