From: ngotogenome@... Date: 2015-11-26T06:06:22+00:00 Subject: [ruby-dev:49387] [Ruby trunk - Bug #11742] [Open] lib/webrick/utils.rb:196:in `register': ERROR RuntimeError: can't add a new key into hash during iteration Issue #11742 has been reported by Naohisa Goto. ---------------------------------------- Bug #11742: lib/webrick/utils.rb:196:in `register': ERROR RuntimeError: can't add a new key into hash during iteration https://bugs.ruby-lang.org/issues/11742 * Author: Naohisa Goto * Status: Open * Priority: Normal * Assignee: * ruby -v: - * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- 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--(?\S+)/ to match "\n\n Internal Server Error\n \n

Internal Server Error

\n can't add a new key into hash during iteration\n
\n
\n WEBrick/1.3.1 (Ruby/2.3.0/2015-11-26) OpenSSL/1.0.1p at\n 127.0.0.1:46098\n
\n \n\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` しているのが、同時に発生したときにエラーが出る? -- https://bugs.ruby-lang.org/