Timeout::ExitException can be raised by nested timeouts
还没有人认领这个 Issue。
- 主要语言
- Ruby
- 星标
- 168
- 派生
- 33
- 平均合并
- 5 小时 58 分钟
- 30 天内合并 PR
- 3
描述
Behavior
Nested timeout blocks can result in a Timeout::ExitException being raised, rather than a Timeout::Error
How to reproduce
The below will sometimes raise a Timeout::ExitException, sometimes a Timeout::Error (roughly 50/50).
begin
Timeout.timeout(2) do
Timeout.timeout(2) do
sleep 3
end
end
rescue Exception => e
puts "raised a #{e.class}"
end
Cause (maybe)
Hacking up the Timeout module as follows:
module Timeout
class Error
def self.handle_timeout(message) # :nodoc:
exc = ExitException.new(message)
begin
puts "yield #{exc.object_id} (#{message})"
yield exc
rescue ExitException => e
puts "test #{e.object_id} vs #{exc.object_id} => #{exc.equal?(e)} (#{message})"
raise new(message) if exc.equal?(e)
puts "re-raise #{e.object_id}('#{e}') (#{message})"
raise
end
end
end
end
Timeout.timeout(2, nil, "outer timeout") do
Timeout.timeout(2, nil, "inner timeout") do
sleep 3
end
end
shows that, when an ExitException is raised, the "inner" exception is being caught by the "outer" handle_timeout block. Suspicious this is the result of indeterminate Thread#raise behavior?
Environment
Ruby 3.3.5
Timeout 0.4.1
Ubuntu 24.04.1 running on WSL2
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行 issue 中嵌套的 Timeout.timeout 复现程序,并检查 Timeout.timeout 路径,尤其是 Timeout::Error.handle_timeout 和 ExitException 处理。确认内部异常能够到达外部处理程序的条件;完成标准是嵌套超时始终引发 Timeout::Error 而不是 Timeout::ExitException,并为该复现程序添加回归检查。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- ruby
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100