exec::start_now: request_stop() on the storage does not reach the senders

オープン
#2,416 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Nas01010101 がすでに取り組んでいます。

2026年11月5日 から。

  • #2417 @Nas01010101 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
cpp
領域
backend

調査の方向性

Read include/exec/async_scope.hpp around __nest_receiver::get_env and include/exec/start_now.hpp around __storage and __receiver to trace which stop token reaches the sender. Then inspect test/exec/async_scope/test_start_now.cpp and add coverage for calling storage.request_stop(); done means the test observes the sender stop instead of run. Pull request #2417 is already open for this issue.

索引モデルが issue の本文から書いたものです。

説明

exec::start_now returns a storage object with request_stop() and get_token(), but a stop request on that object never reaches the started senders. request_stop() returns true and the senders keep running.

Reproducer

#include <stdexec/execution.hpp>
#include <exec/async_scope.hpp>
#include <exec/start_now.hpp>
#include <cstdio>

namespace ex = stdexec;

int main() {
  ex::run_loop loop;
  exec::async_scope scope;
  bool ran = false;
  bool stopped = false;

  auto storage = exec::start_now(
    scope,
    ex::schedule(loop.get_scheduler())
      | ex::then([&]() noexcept { ran = true; })
      | ex::upon_stopped([&]() noexcept { stopped = true; }));

  bool accepted = storage.request_stop();
  loop.finish();
  loop.run();
  ex::sync_wait(scope.on_empty());
  std::printf("request_stop=%d ran=%d stopped=%d\n", accepted, ran, stopped);
}

Expected: request_stop=1 ran=0 stopped=1

Actual: request_stop=1 ran=1 stopped=0

Tested on main at 081ab7fc with clang 21.1.8 and g++ 14. Calling scope.request_stop() instead of storage.request_stop() does stop the sender, so the run loop's scheduler honors stop requests in this program.

Cause

__storage puts its own token in the environment of __receiver, and then wraps each sender with __scope.nest(...). __nest_receiver::get_env in include/exec/async_scope.hpp overrides get_stop_token with the scope's token, so the sender only ever sees the scope's token. The token from __storage::get_token() compares unequal to the one the sender reads.

test/exec/async_scope/test_start_now.cpp has no test that calls request_stop().

主要言語
C++
スター
2.5k
フォーク
284
平均マージ
2日 32分
マージ済み PR(30日)
88

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/stdexec のほかの issue

NVIDIA/stdexec の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。