Commit 9910a75
Stop capturing stack-local PendingConnection in pool timeout timer (#222)
ConnectionPoolImpl::createNewConnection constructed PendingConnection on
the caller's stack, handed its address to the timeout-timer lambda, and
only then std::move-pushed the entry onto pending_connections_. The
captured pointer dangled as soon as createNewConnection returned, so
the timer callback touched freed memory when it fired.
Emplace an empty slot on pending_connections_ first and bind the timer
capture to that list element. std::list guarantees per-element address
stability across push/erase of other elements, which is the invariant
the capture relies on.
onConnectionTimeout previously compacted the list via std::remove_if
plus list::erase. The non-member remove_if moves elements to shuffle
the erased one to the end — which would move the entry whose timer
lambda is currently executing on top of itself. Switch to
std::list::remove_if (member) so the node is unlinked in place, and
identify it by address rather than unique_ptr equality to avoid
accidentally matching an unrelated entry.1 parent dce6d40 commit 9910a75
1 file changed
Lines changed: 18 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
400 | | - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
401 | 408 | | |
402 | 409 | | |
403 | 410 | | |
404 | | - | |
| 411 | + | |
| 412 | + | |
405 | 413 | | |
406 | 414 | | |
407 | 415 | | |
| |||
413 | 421 | | |
414 | 422 | | |
415 | 423 | | |
416 | | - | |
417 | | - | |
418 | 424 | | |
419 | 425 | | |
420 | 426 | | |
| |||
435 | 441 | | |
436 | 442 | | |
437 | 443 | | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
445 | 451 | | |
446 | 452 | | |
447 | 453 | | |
| |||
0 commit comments