WEBrick::HTTPProxyServer hangs when process exits
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- ruby
- 領域
- backend, networking
調査の方向性
WEBrick::HTTPProxyServer#do_CONNECT とその shutdown パスから始め、続いて参照されている ext/socket/ipsocket.c のクリーンアップコードを確認します。スレッド化されたプロキシの終了を再現し、CONNECT ソケットまたはスレッドの join がハングを引き起こしているかを追跡します。shutdown の動作と nil ソケットのパスが説明され、回帰テストでカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
I have a proxy server running in a thread:
@server = WEBrick::HTTPProxyServer.new(ServerType: Thread, BindAddress: host, Port: port)
when process exists I call @server.shutdown but it hangs forever so that I have to send Ctrl+C. While debugging this issue I figured that def do_CONNECT(req, res) which binds a socket os = TCPSocket.new(host, port) sometimes in ensure block has os set to nil. Which leads me to a question if https://github.com/ruby/ruby/blob/55c771c302f94f1d1d95bf41b42459b4d2d1c337/ext/socket/ipsocket.c#L187 socket can be nil if we take into account inetsock_cleanup(VALUE v) which returns return Qnil;
I fixed the issue by adding raise HTTPStatus::EOFError unless os in ensure block so that we don't interact with the rest of descriptors. Other note is that none of the rescue blocks were called in do_CONNECT.
Update: I still assume that TCPSocket.new returns a socket or raises an error, but in my case I have no idea how I end up with nil as a socket even though we call thgroup.list.each{|th| th.join if th[:WEBrickThread] } in shutdown. Maybe because ruby starts to terminate all threads because main thread exits?
- 主要言語
- Ruby
- スター
- 329
- フォーク
- 114
- 平均マージ
- 1時間 15分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/webrick のほかの issue
-
Retire superfluous quoting of Content-Type: charset [RFC7230]対応中かも @jeremyevans が 72 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
CGI script using LF line breaks in headers causes error対応中かも @paulownia が 613 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
似ている issue
-
SecureRandom.alphanumeric can silently return an empty or wrong-length secret instead of raisingオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
ruby/securerandom#92 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
open-feature/ruby-sdk-contrib#340 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
zold-io/wts.zold.io#651 ·
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
erkamyaman/rust-anything#788 ·
メンテナーはふだん 1 日以内に返信