Fix thread_pool shutdown race#199
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughReplaces Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
thread_pool::impl::stop() set the stop_ flag without holding the mutex, creating a window where notify_all() could fire before a worker thread entered cv_.wait(), causing a permanent hang. This was the root cause of async_event test timeouts on slower FreeBSD CI runners. Fix by acquiring the mutex before setting stop_, per the C++ standard requirement that shared variables used in condition_variable predicates must be modified under the mutex. Also demote stop_ from std::atomic<bool> to plain bool since all accesses are now mutex-protected.
0b568f0 to
04146ae
Compare
|
An automated preview of the documentation is available at https://199.capy.prtest3.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-03-04 16:26:47 UTC |
|
GCOVR code coverage report https://199.capy.prtest3.cppalliance.org/gcovr/index.html Build time: 2026-03-04 16:34:40 UTC |
|
GCOVR code coverage report https://199.capy.prtest3.cppalliance.org/gcovr/index.html Build time: 2026-03-04 16:40:29 UTC |
thread_pool::impl::stop()set thestop_flag without holding the mutex, creating a window wherenotify_all()could fire before a worker thread enteredcv_.wait(), causing a permanent hang. This was the root cause of async_event test timeouts on slower FreeBSD CI runners.Fix by acquiring the mutex before setting
stop_, per the C++ standard requirement that shared variables used in condition_variable predicates must be modified under the mutex.Also demote
stop_fromstd::atomic<bool>to plain bool since all accesses are now mutex-protected.Summary by CodeRabbit