Skip to content

[C++] - Fix shutdown race condition#40849

Closed
jbcm1234 wants to merge 2 commits intogrpc:masterfrom
jbcm1234:jf/shutdown-race-fix
Closed

[C++] - Fix shutdown race condition#40849
jbcm1234 wants to merge 2 commits intogrpc:masterfrom
jbcm1234:jf/shutdown-race-fix

Conversation

@jbcm1234
Copy link
Copy Markdown

@jbcm1234 jbcm1234 commented Oct 6, 2025

A race condition exists in the channel shutdown code between the thread calling WorkStealingThreadPoolImpl::Quiesce() and a worker thread in WorkStealingThreadPool::ThreadState::Step().

Referring to these threads as thread A (Quiesce thread) and thread B (Step thread),
it is possible that the following sequence occurs:

  • Thread A calls SetShutdown(true)
  • Thread B does not see the update to shutdown_ before waiting on the work signal.
  • Before thread B waits on the work signal with WaitWithTimeout thread A broadcasts the signal.
  • Thread B now enters WaitWithTimeout but has to wait for the timeout to expire as the signal / condition variable was signalled before it started waiting on it.

This timeout can be in the order of seconds and will stall the thread calling Quiesce until the worker thread (thread B in the above scenario) exits.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Oct 6, 2025

CLA Not Signed

@markdroth
Copy link
Copy Markdown
Member

We can't look at this until you sign the CLA.

@markdroth markdroth closed this Jan 20, 2026
@markdroth markdroth reopened this Jan 20, 2026
@markdroth
Copy link
Copy Markdown
Member

The CLA still hasn't been signed, so we can't look at this. Feel free to open a new PR once you can sign the CLA.

@markdroth markdroth closed this Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants