[#21225] Re: [ruby-cvs] ruby: * enum.c (inject_i): use rb_yield_values. — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

14 messages 2003/08/22
[#21227] Re: [ruby-cvs] ruby: * enum.c (inject_i): use rb_yield_values. — nobu.nakada@... 2003/08/22

なかだです。

[#21228] Re: [ruby-cvs] ruby: * enum.c (inject_i): use rb_yield_values. — matz@... (Yukihiro Matsumoto) 2003/08/22

まつもと ゆきひろです

[#21281] 大量メモリ消費攻撃に対する対応 — Hidetoshi NAGAI <nagai@...>

永井@知能.九工大です.

16 messages 2003/08/29
[#21285] Re: 大量メモリ消費攻撃に対する対応 — matz@... (Yukihiro Matsumoto) 2003/08/29

まつもと ゆきひろです

[#21288] Re: 大量メモリ消費攻撃に対する対応 — Hidetoshi NAGAI <nagai@...> 2003/08/29

永井@知能.九工大です.

[#21306] Re: 大量メモリ消費攻撃に対する対応 — matz@... (Yukihiro Matsumoto) 2003/09/03

まつもと ゆきひろです

[ruby-dev:21272] Fwd: SEGV with net/http

From: Minero Aoki <aamine@...>
Date: 2003-08-27 04:51:17 UTC
List: ruby-dev #21272
青木です。

net/http を使ってたら落ちた、というメールが来たのでとりあえず
転送します。

i686-linux なので家でも落とせるかと思ったんですが、再現しません
でした。バックトレースその他が必要そうなら頼んでみます。
-------------------------------------------------------------------
青木峰郎

Subject: net/http.rb
From: "Raymond D. Mosteller" <rmostell@usc.edu>
To: Minero Aoki <aamine@loveruby.net>
Date: Mon, 25 Aug 2003 15:52:54 -0700

Minero Aoki <aamine@loveruby.net>

Dear Mr. Aoki,

Thank you very much for all of your hard work and dedication to Ruby
development.  I sincerely appreciate your contributions to Ruby.

I have written a Ruby program (my_webchxr.rb) for checking links on my
webpages using the net/http.rb Ruby library.  Each time the program runs it
checks 900+ links for me on 22 web pages.  Most of the time calls to
http.rb work very well.  However, once every few thousand calls, my program
terminates abnormally and gives one of two messages regarding line 1547 in
http.rb (see examples below).  This occurs sporadically and is not
connected to any specific host or path values.  I have tried very hard to
fix this problem myself but have been unsuccessful even after reading all
the excellent documentation in http.rb.  Because you are the author of the
http.rb library, I thought perhaps you could advise me how to avoid this
program failure.

I apologize in advance if this is a really stupid question.

Thank you for your kindness,
Ray Mosteller
rmostell@usc.edu

My system is a Pentium 500 MHz machine with 128 MB RAM running Mandrake
Linux 9.0

#--------------------------------------------
Example #1:

/usr/local/lib/ruby/1.8/net/http.rb:1547: [BUG] Segmentation fault
ruby 1.8.0 (2003-08-04) [i686-linux]

(no traceback is given after the above message)

#--------------------------------------------
Example #2a: (using get method)

/usr/local/lib/ruby/1.8/net/http.rb:1547:in `read_status_line': method `[]'
called on terminated object (0x40193008) (NotImplementedError)
	from /usr/local/lib/ruby/1.8/net/http.rb:1528:in `read_new'
	from /usr/local/lib/ruby/1.8/net/http.rb:819:in `request'
	from /usr/local/lib/ruby/1.8/net/http.rb:809:in `request'
	from /usr/local/lib/ruby/1.8/net/http.rb:807:in `start'
	from /usr/local/lib/ruby/1.8/net/http.rb:810:in `request'
	from /usr/local/lib/ruby/1.8/net/http.rb:604:in `get'
	from my_webchxr.rb:65:in `check_html_data'
	from my_webchxr.rb:120:in `check_href'
	from my_webchxr.rb:117:in `each'
	from my_webchxr.rb:117:in `check_href'
	from my_webchxr.rb:187:in `main_loop'
	from my_webchxr.rb:180:in `each'
	from my_webchxr.rb:180:in `main_loop'
	from my_webchxr.rb:201

#--------------------------------------------
Example #2b: (using head method)

/usr/local/lib/ruby/1.8/net/http.rb:1547:in `read_status_line': method `[]'
called on terminated object (0x40193094) (NotImplementedError)
	from /usr/local/lib/ruby/1.8/net/http.rb:1528:in `read_new'
	from /usr/local/lib/ruby/1.8/net/http.rb:819:in `request'
	from /usr/local/lib/ruby/1.8/net/http.rb:809:in `request'
	from /usr/local/lib/ruby/1.8/net/http.rb:807:in `start'
	from /usr/local/lib/ruby/1.8/net/http.rb:810:in `request'
	from /usr/local/lib/ruby/1.8/net/http.rb:633:in `head'
	from my_webchxr.rb:42:in `check_html_headers'
	from my_webchxr.rb:119:in `check_href'
	from my_webchxr.rb:118:in `each'
	from my_webchxr.rb:118:in `check_href'
	from my_webchxr.rb:196:in `main_loop'
	from my_webchxr.rb:187:in `each'
	from my_webchxr.rb:187:in `main_loop'
	from my_webchxr.rb:212


#--------------------------------------------
Example 2c: (using request_head method)

/usr/local/lib/ruby/1.8/net/http.rb:1547:in `read_status_line': method `[]'
called on terminated object (0x40193030) (NotImplementedError)
	from /usr/local/lib/ruby/1.8/net/http.rb:1528:in `read_new'
	from /usr/local/lib/ruby/1.8/net/http.rb:819:in `request'
	from /usr/local/lib/ruby/1.8/net/http.rb:736:in `request_head'
	from my_webchxr.rb:55:in `check_html_headers'
	from my_webchxr.rb:156:in `check_href'
	from my_webchxr.rb:155:in `each'
	from my_webchxr.rb:155:in `check_href'
	from my_webchxr.rb:232:in `main_loop'
	from my_webchxr.rb:223:in `each'
	from my_webchxr.rb:223:in `main_loop'
	from my_webchxr.rb:248

#--------------------------------------------

code from http.rb:  (line 1547 is labeled)

      def read_status_line( sock )
        str = sock.readline
        m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)\s*(.*)\z/in.match(str) or
                raise HTTPBadResponse, "wrong status line: #{str.dump}"
        m.to_a[1,3]	# line 1547
      end
	
#--------------------------------------------
This is code from my_webchxr.rb:

def check_html_headers(url)
# check html headers on url
# return nil if OK
# return error msg if not ok

  host,path = urlparse(url)

  # used with ruby 1.6.7 and 1.6.8, http 1.1
  # Net::HTTP.version_1_1  # declare to use ver 1.1 features
  # h = Net::HTTP.new(host,80)
  # reply = h.head(path,nil)
  # re = /^30[12]/  # error codes 301/302 are OK (moved)

  # use with ruby 1.8.0, http 1.2
  Net::HTTP.version_1_2  # declare to use ver 1.2 features
  http = Net::HTTP.start(host, 80)
  reply = http.request_head(path)

  puts "Check_headers1: #{url} Code = #{reply.code} Msg = #{reply.message}"

  return nil if /^(2|3)\d\d/ =~ reply.code	# OK if code = 200 or 30x (moved)
  return "http://#{url}  Request_head error: #{reply.code} Msg =
#{reply.message}\n"

  rescue Timeout::Error => errmsg
    puts "Check_headers2: #{url}  Timeout::Error: #{errmsg}"
    return "http://#{url}  Timeout::Error: #{errmsg}\n"

  rescue => errmsg
    puts "Check_headers3: #{url}  Other Error: #{errmsg}"
    # return nil if re =~ errmsg   # error codes 301/302 are OK (moved)
    return "http://#{url}  Other Error: #{errmsg}\n"

end

def check_html_data(url)
# check hdr and html data on url
# return nil if OK
# return error msg if not OK

  host,path = urlparse(url)

  # used with ruby 1.6.7 and 1.6.8, http 1.1
  # Net::HTTP.version_1_1  # declare to use ver 1.1 features
  # h = Net::HTTP.new(host,80)
  # hdr,data = h.get(path,nil)
  # puts "Check_data1: #{url}  Code = #{hdr.code} Msg = #{hdr.message}"
  # re = /^30[12]/  # error codes 301/302 are OK (website moved)

  # use with ruby 1.8.0, http 1.2
  Net::HTTP.version_1_2  # declare to use ver 1.2 features
  http = Net::HTTP.start(host, 80)
  reply = http.request_get(path)

  puts "Check_data1: #{url}  Code = #{reply.code} Msg = #{reply.message}"

  return nil if /^(2|3)\d\d/ =~ reply.code	# OK if code = 200 or 30x (moved)
  return "http://#{url}  Request_get error: #{reply.code} Msg =
#{reply.message}\n"


  rescue Timeout::Error => errmsg
    puts "Check_data2: #{url}  Timeout::Error: #{errmsg}\n"
    return "http://#{url}  Timeout::Error: #{errmsg}\n"

  rescue => errmsg
    puts "Check_data3: #{url}  Other Error: #{errmsg}\n"
    # return nil if re =~ errmsg   # error codes 301/302 are OK (website
moved)
    return "http://#{url}  Other Error: #{errmsg}\n"

end

In This Thread

Prev Next