Project

General

Profile

Actions

Bug #11742

closed

lib/webrick/utils.rb:196:in `register': ERROR RuntimeError: can't add a new key into hash during iteration

Added by ngoto (Naohisa Goto) over 8 years ago. Updated about 8 years ago.

Status:
Closed
Target version:
-
[ruby-dev:49387]

Description

RubyCI上にて、たまに以下のFailureが発生しています。

  1) Failure:
TestNetHTTP_v1_2_chunked#test_set_form [/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/test/net/http/test_http.rb:679]:
Expected /\A--(?<boundary>\S+)/ to match "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n<HTML>\n  <HEAD><TITLE>Internal Server Error</TITLE></HEAD>\n  <BODY>\n    <H1>Internal Server Error</H1>\n    can't add a new key into hash during iteration\n    <HR>\n    <ADDRESS>\n     WEBrick/1.3.1 (Ruby/2.3.0/2015-11-26) OpenSSL/1.0.1p at\n     127.0.0.1:46098\n    </ADDRESS>\n  </BODY>\n</HTML>\n".

  2) Failure:
TestNetHTTP_v1_2_chunked#test_set_form [/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/test/net/http/utils.rb:46]:
<[]> expected but was
<["[2015-11-26 03:54:25] ERROR RuntimeError: can't add a new key into hash during iteration\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/utils.rb:196:in `register'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/utils.rb:139:in `block in register'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/utils.rb:138:in `synchronize'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/utils.rb:138:in `register'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/utils.rb:227:in `timeout'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/httprequest.rb:519:in `_read_data'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/httprequest.rb:530:in `read_line'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/httprequest.rb:491:in `read_chunk_size'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/httprequest.rb:510:in `read_chunked'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/httprequest.rb:470:in `read_body'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/httprequest.rb:255:in `body'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/test/net/http/utils.rb:91:in `do_POST'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/httpservlet/abstract.rb:106:in `service'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/httpserver.rb:139:in `service'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/httpserver.rb:95:in `run'\n\t/home/rubyci/unstable11s/tmp/build/20151126T012513Z/ruby/lib/webrick/server.rb:295:in `block in start_thread'\n"]>.

上記は Solaris 11 sparc ですが、他のOS・アーキテクチャでも発生しているときがあるようです。

@timeout_info へのアクセスの排他制御が考慮されていないように見えます。
initializeメソッド内で起動されるスレッド @watcher 内で @timeout_info.each {|thread, ary| を回しているのと、registerメソッド内冒頭で @timeout_info[thread] ||= Array.new しているのが、同時に発生したときにエラーが出る?

Updated by ko1 (Koichi Sasada) over 8 years ago

  • Assignee set to nahi (Hiroshi Nakamura)

yuzo san が担当者一覧に見つかんなかったので、nahi さんにとりあえず振っておきます。
すみませんが、適切な方に delegate して頂けると。

Actions #2

Updated by ngoto (Naohisa Goto) over 8 years ago

  • Status changed from Open to Closed

Applied in changeset r53130.


  • lib/webrick/utils.rb (WEBrick::Utils::TimeoutHandler#initialize):
    TimeoutMutex should be acquired when accessing @timeout_info.
    To avoid deadlock, interrupt() calls are delayed.
    Due to the mutex, it is safe to treat ary without ary.dup.
    [Bug #11742] [ruby-dev:49387]

Updated by ngoto (Naohisa Goto) over 8 years ago

additional commit for this issue: r53201

Updated by usa (Usaku NAKAMURA) about 8 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: REQUIRED

Updated by ngoto (Naohisa Goto) about 8 years ago

WEBrick::Utils::TimeoutHandler がモンキーパッチされていたため、Ruby 2.3 にバージョンアップしたら動かなくなったアプリがあった、と、どこかで見た記憶があります。モンキーパッチは基本は当てる人の責任でいいとは思いますが、参考までに。
https://twitter.com/sora_h/status/686921700756160512

Updated by usa (Usaku NAKAMURA) about 8 years ago

そんなアプリは死んでおけばいいんじゃないですかね^^

互換性をどこまで保つかって難しい判断なわけですが、うーん。
2.1についてはまた後で考えます(そして時間切れで自動的にWONTFIXになる)。

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0