Commit 6896a4d
committed
fix 3243
Fix IOBuf TLS block pool self-loop caused by double-return (#3243)
release_tls_block() and release_tls_block_chain() do not guard against
a block being returned to TLS when it is already the list head. The
assignment `b->portal_next = block_head` becomes `b->portal_next = b`,
forming a self-loop that causes remove_tls_block_chain() or
share_tls_block() to spin forever, silently hanging the thread at exit.
Fix:
- release_tls_block(): add early return when b == block_head, skipping
the duplicate insertion.
- release_tls_block_chain(): during the existing chain walk, check each
node against block_head before linking. Return early if overlap is
detected so that num_blocks stays consistent with the actual list
length (remove_tls_block_chain verifies this via CHECK_EQ).
Add three unit tests that reproduce the self-loop through:
1. Direct double release_tls_block() of the same block.
2. release_tls_block_chain() with a chain overlapping the TLS head.
3. IOBufAsZeroCopyOutputStream::BackUp() followed by a second release.1 parent d5dab28 commit 6896a4d
3 files changed
Lines changed: 381 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
326 | | - | |
| 326 | + | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
330 | 329 | | |
331 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
332 | 336 | | |
333 | 337 | | |
334 | | - | |
| 338 | + | |
| 339 | + | |
335 | 340 | | |
336 | 341 | | |
337 | 342 | | |
338 | 343 | | |
| 344 | + | |
339 | 345 | | |
340 | | - | |
341 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
342 | 356 | | |
343 | | - | |
344 | 357 | | |
345 | 358 | | |
346 | 359 | | |
347 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
348 | 364 | | |
349 | 365 | | |
350 | | - | |
| 366 | + | |
351 | 367 | | |
352 | 368 | | |
353 | 369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
606 | 615 | | |
607 | 616 | | |
608 | 617 | | |
609 | 618 | | |
610 | 619 | | |
611 | 620 | | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
612 | 628 | | |
613 | 629 | | |
614 | 630 | | |
| |||
0 commit comments