Race in `inner_timout_checker`: iterating over `m.start_time_by_pid.items()` can crash with "dictionary changed size during iteration" and leave `mutmut run` hanging
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 52/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- python
- Área
- testing-qa, tooling
Línea de trabajo
Comienza en el punto de entrada inner_timout_checker de main.py, alrededor de la iteración indicada, y sigue las actualizaciones de start_time_by_pid durante mutmut run. Reproduce el problema con Python 3.10 usando python3.10 -m mutmut run y, después, inspecciona la orquestación de los workers y la cobertura existente de pytest. Se considera completado cuando la condición de carrera ya no provoca que el checker falle y el comando no se queda bloqueado con workers restantes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Command
python3.10 -m mutmut run
Observed behavior
During mutation testing, mutmut prints this exception from the timeout-checker background thread:
Exception in thread Thread-1061 (inner_timout_checker):
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/Users/pomponchik/Desktop/Projects/suby/.venv/lib/python3.8/site-packages/mutmut/__main__.py", line 1201, in inner_timout_checker
for pid, start_time in m.start_time_by_pid.items():
RuntimeError: dictionary changed size during iteration
After that, mutmut run appears to hang indefinitely.
I checked the process tree, and the parent python -m mutmut run process plus multiple worker python -m mutmut run children were still alive, but all of them were sleeping at 0.0% CPU. So it looks like once inner_timout_checker crashes, the main orchestration can get stuck forever instead of failing and cleaning up workers.
Expected behavior
inner_timout_checker should not iterate over a dict that can be concurrently mutated without synchronization/copying. And if a background orchestration thread crashes anyway, mutmut run should fail loudly and terminate workers instead of hanging.
Why this looks like a race
The failing line iterates directly over:
for pid, start_time in m.start_time_by_pid.items():
The exception strongly suggests that some other thread mutates m.start_time_by_pid at the same time.
So a minimal fix might be to iterate over a snapshot, e.g. list(m.start_time_by_pid.items()), or guard access with a lock, depending on the intended synchronization model.
Extra note
I first tried running mutmut from a Python 3.8 venv and hit a separate issue:
AttributeError: module 'os' has no attribute 'waitstatus_to_exitcode'
So the hang above was reproduced by running mutmut itself with Python 3.10.8.
Environment
- mutmut: 3.2.3
- OS: macOS 15.3.1 (24D70)
- Python used to run mutmut: 3.10.8
- Test runner: pytest
- Project size: ~245 mutants
- Lenguaje dominante
- Python
- Estrellas
- 1.5k
- Forks
- 185
- Merge medio
- 1 d 14 h
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de boxed/mutmut
-
Removing `not` from a parenthesized multi-line expression drops the parentheses (InvalidGeneratedSyntaxException, 3.8.0)Posiblemente ocupada @jihtsan la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
boxed/mutmut#602 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
`run` with a `name__mutmut_*` pattern runs the whole test suite in the clean-test checkPosiblemente ocupada @Ishaan400 la tomó hace 18 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
boxed/mutmut#592 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Invalid unary plus generated in match statementPosiblemente ocupada @GhostCoder6969 la tomó hace 27 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 2 días
-
What do the emoji's mean?Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
boxed/mutmut#560 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
boxed/mutmut#529 · 7 comentarios ·
Los mantenedores suelen responder en 2 días
Todos los issues de boxed/mutmut
Issues similares
-
No test checks that scheduled workflows declare minimal permissions, concurrency and a timeoutAbiertoci enhancement testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
area/config comp/tools P2 platform/telegram type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
NousResearch/hermes-agent#145412 ·
Los mantenedores suelen responder en 1 día
-
[oblt-aw][autodoc] Update docs for security org scaffolding and Docs AI menu permission changesPosiblemente ocupada @github-actions la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
curriculum documentation quality
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
githubnext/gh-aw-workshop#5039 ·
Los mantenedores suelen responder en 1 día
-
Community project: hosted MOSS-Image studio with a visual JSON layout builder (no ComfyUI needed)Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 65/100
OpenMOSS/MOSS-Image#27 · 1 comentario ·
Los mantenedores suelen responder en 1 día