UCT/TCP/SOCKCM: Close pending server endpoints on listener destroy #12465
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 222 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.323
Real PR Conversation Timeline
1 comments
"Review active on #12465"
general
weight: 0.35
tvegas1
What?
When a TCP sockcm listener is destroyed, close the server endpoints it accepted whose connection request hasn't been passed to the user yet.
Why?
A connection accepted by the TCP sockcm listener gets a server endpoint that keeps a pointer to the listener (
ep->listener) until the client's private data arrives. Only then does it invoke the listener'sconn_request_cb.uct_listener_destroy()only closed the listening socket and left those endpoints insockcm->ep_listwith their async handlers registered. When the client's data arrived later, the callback was invoked through the freed listener: a heap-use-after-free, usually a segfault inuct_tcp_sockcm_ep_server_invoke_conn_req_cb(),ucp_cm_server_conn_request_cb()oruct_listener_reject().Applications hit this when they destroy a listener (
ucp_listener_destroy()) while clients are still connecting.How?
UCS_CLASS_CLEANUP_FUNC(uct_tcp_listener_t)now walkssockcm->ep_listunder the async lock and closes the endpoints whoselisteneris the one being destroyed. It usesuct_tcp_sockcm_close_ep(), the same helper the CM cleanup already uses. Endpoints whose connection request was already passed to the user are removed fromep_listbefore the callback is invoked, so they're not affected. The client sees its connection closed.The new test
test_uct_sockaddr_tcp.destroy_listener_with_pending_conn_requestconnects a plain TCP socket to the listener and waits until the listener has accepted it. It then destroys the listener and checks three things:Without the fix, the test fails at the first check.