Commit de94b35
comms/uniflow/tcp: refuse a bind() on a transport that is already bound
Summary:
bind() guarded only shutdown_, then set state_ = Initialized unconditionally.
Initialized is the one state connect() admits, so a second bind() re-armed that
gate on a live transport and nothing rejected the second connect() that follows.
Two things go wrong on that path. bind() itself calls servers_.clear(), dropping
the listener out from under an established connection. Then the second connect()
reaches establishLanes(), whose first act is lanes_.clear() -- and a TcpLane owns
its reader and sender std::threads, so that destroys two joinable threads.
~std::thread on a joinable thread calls std::terminate unconditionally. The lane's
Conn is destroyed in the same sweep while both threads are still using it, so
there is a use-after-free behind the terminate as well.
This needs caller misuse: the Transport contract is bind-then-connect once, and
nothing in tree re-binds -- MultiTransport::bind() fails the whole bind when a
transport returns empty info, and Uniflow::establishConnection() binds each
freshly created transport once. But the failure mode is a process-wide abort with
no diagnostic, and on AMD this transport shares a MultiTransport with RDMA, so it
would take down transports that did nothing wrong. The refusal costs three lines
next to the shutdown_ check that is already there.
Error is treated as terminal here too. A bind() that failed leaves state_ = Error,
and this guard therefore refuses a retry. Nothing retries today, and a transport
whose listener never came up should not be revived by a second attempt against
the same host_.
Differential Revision: D1178846131 parent 981a7ce commit de94b35
2 files changed
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
331 | 343 | | |
332 | 344 | | |
333 | 345 | | |
| |||
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
195 | 232 | | |
196 | 233 | | |
197 | 234 | | |
| |||
0 commit comments