bregctl dev: a detached supervisor can inherit another start's output pipe, hanging parallel installed-dev tests

Abierto
#2,631 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
rust
Área
cli, testing

Línea de trabajo

Start with crates/registry-bregctl/tests/dev_lifecycle.rs and trace Session::start() and run_supervisor() to see how the detached process handles inherited file descriptors. Review the macOS process spawning path and reproduce by running the installed-dev tests in parallel. Done when concurrent starts return within a bound and the regression test passes.

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

Descripción

area:breg bug rust

What happens

Running the installed-dev tests in crates/registry-bregctl/tests/dev_lifecycle.rs in parallel can hang one test indefinitely on macOS. The hung test is waiting in Command::output() for EOF on its child's stdout pipe. lsof during a hang showed the write end of that pipe held open by a different test's detached bregctl dev supervisor and the breg server it started, so the read never ends.

Likely cause (medium-high confidence)

On macOS, Rust's standard library creates pipes with pipe() and sets FD_CLOEXEC afterwards, which is not atomic. When two threads call Session::start() at once, one bregctl dev start child can inherit the other thread's pipe write end before FD_CLOEXEC is set. That child then hands the descriptor to its detached supervisor (run_supervisor calls setsid() but keeps inherited descriptors), which keeps it open for the life of the dev environment. The fd numbers matched; the fork itself was not caught.

The same inheritance would affect an operator who starts two dev environments from one parent process, though that is less likely outside tests.

Candidate fixes

  • When detaching the supervisor, close every inherited descriptor above 2 (or reopen 0 to 2 on /dev/null and close the rest).
  • Or spawn the supervisor with posix_spawn and POSIX_SPAWN_CLOEXEC_DEFAULT, passing only the descriptors it needs.

A regression test can start two sessions concurrently and assert that each dev start returns within a bound.

Found while verifying the external record projections branch (feat/breg-external-views).

Lenguaje dominante
Rust
Estrellas
2
Forks
0
Merge medio
9 h 48 min
PR fusionados (30 d)
151

Preparar el entorno

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 registrystack/registry-stack

Todos los issues de registrystack/registry-stack

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.