IOSim: timeout can return while its assasin threas is still ailve
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Start by reading the IOSim implementation of timeout, its assassin thread, and the runSimStrictShutdown checks; the issue gives six reproductions using threadDelay, yield, and STM. Trace the tie cases where the assassin remains queued or has a pending ThreadKilled, then verify that all scenarios finish without FailureSloppyShutdown while preserving their stated results.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
timeout can return while its assassin thread is still alive, so runSimStrictShutdown fails with FailureSloppyShutdown
In IOSim, timeout forks an assassin thread when its timer fires. If the action finishes at the same moment the timeout expires, timeout can return while the assassin is still alive. Any simulation run with runSimStrictShutdown then fails with FailureSloppyShutdown.
The result itself is correct: the leftover assassin never throws. But in simulations the action often finishes exactly at the deadline, so this makes strict shutdown unusable for code that uses timeout. GHC has no equivalent of the strict-shutdown check, so the problem only shows up in the simulator.
To Reproduce
Each scenario run with runSimStrictShutdown:
| Scenario | Code | Result |
|---|---|---|
| a. timer never fires | timeout 1 (threadDelay 0.5) |
Just () |
| b. timeout wins | timeout 1 (threadDelay 2) |
Nothing |
| c. tie, action finishes first | timeout 1 (threadDelay 1) |
FailureSloppyShutdown |
c′. c, then yield |
timeout 1 (threadDelay 1) <* yield |
FailureSloppyShutdown |
| d. tie, action yields before finishing | timeout 1 (threadDelay 1 >> atomically (pure ())) |
FailureSloppyShutdown |
d′. d, then yield |
timeout 1 (threadDelay 1 >> atomically (pure ())) <* yield |
Just () |
- Case c: the assassin hasn't run yet. At 1s the delay timer wakes the main thread, and the timeout timer forks the assassin, which is queued behind main.
Main leaves the TimeoutFrame, takes the lock and finishes. The assassin is still in the run queue, so TraceMainReturn lists it as running. A yield
doesn't help: the assassin's tryPutTMVar commit yields too, so main finishes before the assassin exits. - Case d: the assassin holds the lock but hasn't thrown yet. The frame exit killThreads it. Killing an unmasked thread doesn't block; it only replaces the
thread's next action with Throw ThreadKilled. So the assassin isn't dead yet when main finishes. One yield lets it terminate, which is why d′ passes.
- Lingua principale
- Haskell
- Stelle
- 57
- Fork
- 25
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
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 IntersectMBO/io-sim
-
`timeout` under `mask_`: a cancelled assassin's exception is delivered after the frameForse già presa @coot l’ha presa 12 giorni fa. Apertabug
IntersectMBO/io-sim#269 · 1 assegnatario ·
-
Implement a workaround for "Overwhelming the TimerManager"Forse di nuovo libera @coot l’ha presa 32 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
IntersectMBO/io-sim#268 · 1 commento · 1 assegnatario ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
IntersectMBO/io-sim#258 ·
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 55/100
IntersectMBO/io-sim#248 · 1 commento ·
-
SimEvent redesignAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
IntersectMBO/io-sim#244 · 1 commento ·
Tutte le issue di IntersectMBO/io-sim
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
pkg:crucible-mir type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Heroes in statisticsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100