IOSim: timeout can return while its assasin threas is still ailve
还没有人认领这个 Issue。
评估
调研方向
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 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 天前认领,目前没有进行中的 PR。 未关闭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 条评论 ·
-
难度 5/5 一周以上 新手友好度 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
-
难度 2/5 1-3 小时 新手友好度 68/100