Skip to content

docs: document strand/thread_pool teardown precondition (#348)#354

Merged
mvandeberg merged 1 commit into
cppalliance:develop-2from
mvandeberg:pr/348-strand-teardown
Jul 2, 2026
Merged

docs: document strand/thread_pool teardown precondition (#348)#354
mvandeberg merged 1 commit into
cppalliance:develop-2from
mvandeberg:pr/348-strand-teardown

Conversation

@mvandeberg

Copy link
Copy Markdown
Contributor

A strand holds only a non-owning reference to its execution context. Posting or dispatching to a strand concurrently with, or after, that context's destruction is undefined behavior: it races service teardown (the #348 null-deref of service_) and, past destroy(), a use-after-free on the freed service state and pool queue.

This is a precondition violation, not a bug reachable by correct code: legitimate posts run on pool workers, and join()-before-shutdown() already ensures no worker is active when the service tears down. The safe pattern is to submit work through run/run_async (work-tracked, so join() waits for it) and to join() the context before destroying it.

Document the requirement on strand (class + post()/dispatch()) and on the thread_pool destructor. No code change.

)

A strand holds only a non-owning reference to its execution context.
Posting or dispatching to a strand concurrently with, or after, that
context's destruction is undefined behavior: it races service teardown
(the cppalliance#348 null-deref of service_) and, past destroy(), a use-after-free
on the freed service state and pool queue.

This is a precondition violation, not a bug reachable by correct code:
legitimate posts run on pool workers, and join()-before-shutdown()
already ensures no worker is active when the service tears down. The
safe pattern is to submit work through run/run_async (work-tracked, so
join() waits for it) and to join() the context before destroying it.

Document the requirement on strand (class + post()/dispatch()) and on
the thread_pool destructor. No code change.
@github-project-automation github-project-automation Bot moved this to Backlog in Beast2 Jul 2, 2026
@mvandeberg mvandeberg merged commit 31b0d97 into cppalliance:develop-2 Jul 2, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Beast2 Jul 2, 2026
@mvandeberg mvandeberg deleted the pr/348-strand-teardown branch July 2, 2026 17:18
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.29%. Comparing base (fa088fb) to head (5082702).
⚠️ Report is 2 commits behind head on develop-2.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop-2     #354   +/-   ##
==========================================
  Coverage      98.29%   98.29%           
==========================================
  Files             77       79    +2     
  Lines           3984     3986    +2     
==========================================
+ Hits            3916     3918    +2     
  Misses            68       68           
Flag Coverage Δ
linux 98.29% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 4 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa088fb...5082702. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant