IOSim: timeout can return while its assasin threas is still ailve
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Haskell
- スター
- 57
- フォーク
- 25
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
IntersectMBO/io-sim のほかの issue
-
`timeout` under `mask_`: a cancelled assassin's exception is delivered after the frame対応中かも @coot が 12 日前に担当しました。 オープンbug
IntersectMBO/io-sim#269 · 担当者 1 名 ·
-
Implement a workaround for "Overwhelming the TimerManager"再び着手できるかも @coot が 32 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンenhancement
IntersectMBO/io-sim#268 · コメント 1 件 · 担当者 1 名 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
IntersectMBO/io-sim#258 ·
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 55/100
IntersectMBO/io-sim#248 · コメント 1 件 ·
-
SimEvent redesignオープン
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
IntersectMBO/io-sim#244 · コメント 1 件 ·
IntersectMBO/io-sim の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
pkg:crucible-mir type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Heroes in statisticsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100