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

Abierto
#2,416 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Nas01010101 ya está trabajando en esto.

Desde el 5/11/2026.

  • #2417 de @Nas01010101 — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
cpp
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
C++
Estrellas
2.5k
Forks
284
Merge medio
2 d 32 min
PR fusionados (30 d)
88

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NVIDIA/stdexec

Todos los issues de NVIDIA/stdexec

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.