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

Đang mở
#2,416 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Nas01010101 đang làm issue này rồi.

Từ ngày 5/11/2026.

  • #2417 của @Nas01010101 — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
cpp
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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().

Ngôn ngữ chính
C++
Star
2.5k
Fork
284
Merge trung bình
2 ngày 32 phút
Pull request đã merge (30 ngày)
88

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NVIDIA/stdexec

Tất cả issue của NVIDIA/stdexec

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.