Commit 4379fc6
ignore: fix parallel walker hang when visitor panics
When a visitor callback panics during parallel directory traversal,
the panic unwinds past Worker::run() without signaling other workers
to stop. Those workers then spin indefinitely in their work-stealing
sleep loop because:
1. active_workers is never decremented for the panicked thread
2. quit_now is never set
3. The sleep loop in get_work() never checks quit_now
This manifests as the process hanging with threads stuck in
nanosleep(2), as reported in #3009.
The fix has three parts:
- Add a WorkerPanicGuard (Drop guard) to Worker::run() that sets
quit_now on unwind, ensuring all sibling workers see the signal.
- Add a quit_now check to the inner sleep loop in get_work(), so
workers blocked waiting for work break out immediately when a
sibling signals termination.
- Replace handle.join().unwrap() with graceful panic collection:
join all threads first, then resume_unwind with the first panic
payload. This prevents the join loop from aborting before all
threads have exited.
This also partially mitigates #2761 (nanosleep spin when a thread
is blocked on a FIFO), since the quit_now check in the sleep loop
provides an escape hatch that was previously missing.
Closes #30091 parent 4519153 commit 4379fc6
1 file changed
+90
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1424 | 1424 | | |
1425 | 1425 | | |
1426 | 1426 | | |
| 1427 | + | |
1427 | 1428 | | |
1428 | | - | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
1429 | 1439 | | |
1430 | 1440 | | |
1431 | 1441 | | |
| |||
1622 | 1632 | | |
1623 | 1633 | | |
1624 | 1634 | | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
1625 | 1665 | | |
1626 | 1666 | | |
1627 | 1667 | | |
1628 | 1668 | | |
1629 | 1669 | | |
1630 | 1670 | | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
1631 | 1675 | | |
1632 | 1676 | | |
1633 | 1677 | | |
1634 | 1678 | | |
1635 | 1679 | | |
| 1680 | + | |
1636 | 1681 | | |
1637 | 1682 | | |
1638 | 1683 | | |
| |||
1836 | 1881 | | |
1837 | 1882 | | |
1838 | 1883 | | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
1839 | 1890 | | |
1840 | 1891 | | |
1841 | 1892 | | |
| |||
2491 | 2542 | | |
2492 | 2543 | | |
2493 | 2544 | | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
2494 | 2583 | | |
0 commit comments