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

Aperta
#2,416 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Nas01010101 ci sta già lavorando.

Dal 5/11/2026.

  • #2417 di @Nas01010101 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
cpp
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
C++
Stelle
2.5k
Fork
284
Merge medio
2g 32m
PR unite (30g)
88

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NVIDIA/stdexec

Tutte le issue di NVIDIA/stdexec

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.