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
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- python
- Ambito
- testing-qa, tooling
Direzione di ricerca
Inizia dal punto di ingresso inner_timout_checker in main.py, intorno all’iterazione segnalata, e traccia gli aggiornamenti di start_time_by_pid durante mutmut run. Riproduci il problema con Python 3.10 usando python3.10 -m mutmut run, quindi esamina l’orchestrazione dei worker e la copertura pytest esistente. Il lavoro è completato quando la race condition non causa più il crash del checker e il comando non rimane bloccato con worker lasciati indietro.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 1.5k
- Fork
- 179
- Merge medio
- 1g 18h
- PR unite (30g)
- 6
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di boxed/mutmut
-
`run` with a `name__mutmut_*` pattern runs the whole test suite in the clean-test checkForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Invalid unary plus generated in match statementForse già presa @GhostCoder6969 l’ha presa 9 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
What do the emoji's mean?Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
boxed/mutmut#560 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
boxed/mutmut#529 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
boxed/mutmut#503 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di boxed/mutmut
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
MystenLabs/MemWal#1163 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
infertopics leaves new nodes without a topic when untopiced neighbours outnumber topiced onesForse già presa @moneebullah25 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
FinanceFlash/unvibecode#218 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
NVIDIA/earth2studio#1241 ·
I maintainer di solito rispondono entro 3 giorni