stdexec::when_all: Hang After Stop Request#1851
Merged
ericniebler merged 1 commit intoNVIDIA:mainfrom Feb 16, 2026
Merged
Conversation
std::execution::when_all forwards stop requests through to its children
via the exposition-only class on-stop-request, defined as follows (see
[exec.snd.general]):
struct on-stop-request {
inplace_stop_source& stop-src; // exposition only
void operator()() noexcept { stop-src.request_stop(); }
};
stdexec::when_all used to be conforming in this regard, however this
changed in 36a92fd. That commit not
only complicates the stop callback used by stdexec::when_all but also
causes the __stopped state to be reachable even when no child is capable
of sending a stopped completion signal. The change to std::execution::
when_all introduced by P3887 (see
712953b) depends on the __stopped state
being impossible unless a child sends a stopped completion signal. This
tension meant that 36a92fd caused
stdexec::when_all to not complete (thereby leading to hangs) when:
- No child potentially sent a stopped completion signal, and
- Stop was requested
712953b intended to include a unit test
preventing the above-described regression but due to a typo (corrected
in this commit) that unit test failed in this regard.
Note that 36a92fd is a misdiagnosis and
should eventually be reverted (along with this commit save the above-
mentioned unit test correction). The issue that
36a92fd aims to address has nothing to
do with stdexec::when_all and is instead caused by the fact that
stdexec::inplace_stop_source is not well-behaved when the lifetime of
the stop source ends during the dispatch of the final stop callback.
This issue should be fixed separately and this commit is only intended
to workaround the issue in the meantime.
ericniebler
approved these changes
Feb 16, 2026
Collaborator
|
/ok to test b4de0c7 |
Collaborator
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
std::execution::when_all forwards stop requests through to its children via the exposition-only class on-stop-request, defined as follows (see [exec.snd.general]):
stdexec::when_all used to be conforming in this regard, however this changed in 36a92fd. That commit not only complicates the stop callback used by stdexec::when_all but also causes the __stopped state to be reachable even when no child is capable of sending a stopped completion signal. The change to std::execution:: when_all introduced by P3887 (see 712953b) depends on the __stopped state being impossible unless a child sends a stopped completion signal. This tension meant that 36a92fd caused stdexec::when_all to not complete (thereby leading to hangs) when:
712953b intended to include a unit test preventing the above-described regression but due to a typo (corrected in this commit) that unit test failed in this regard.
Note that 36a92fd is a misdiagnosis and should eventually be reverted (along with this commit save the above- mentioned unit test correction). The issue that
36a92fd aims to address has nothing to do with stdexec::when_all and is instead caused by the fact that stdexec::inplace_stop_source is not well-behaved when the lifetime of the stop source ends during the dispatch of the final stop callback. This issue should be fixed separately and this commit is only intended to workaround the issue in the meantime.
Addresses #1849, fixes issue introduced by #1718.