Skip to content

stdexec::when_all: Hang After Stop Request#1851

Merged
ericniebler merged 1 commit intoNVIDIA:mainfrom
RobertLeahy:when_all_workaround_20260216
Feb 16, 2026
Merged

stdexec::when_all: Hang After Stop Request#1851
ericniebler merged 1 commit intoNVIDIA:mainfrom
RobertLeahy:when_all_workaround_20260216

Conversation

@RobertLeahy
Copy link
Contributor

@RobertLeahy RobertLeahy commented Feb 16, 2026

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.

Addresses #1849, fixes issue introduced by #1718.

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.
@copy-pr-bot
Copy link

copy-pr-bot bot commented Feb 16, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ericniebler
Copy link
Collaborator

/ok to test b4de0c7

@ericniebler ericniebler merged commit 3518e31 into NVIDIA:main Feb 16, 2026
36 of 37 checks passed
@ericniebler
Copy link
Collaborator

thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants