Project

General

Profile

Backport #1329

Ruby 1.8.8 で "p eval('0' + '+0.1'*n)" が Segmentation Fault を発生させる

Added by mrkn (Kenta Murata) over 10 years ago. Updated over 8 years ago.

Status:
Assigned
Priority:
Normal

Description

=begin
"p eval('0' + '+0.1'*n)" を評価すると、
n がある値 N1 を超えたときに TypeError が、
N2 を超えたときに Segmentation Fault が発生します。
N1 と N2 がアーキテクチャに依存するかどうかは調べてません。

$ ~/ruby-1.8.8-r23009/bin/ruby -ve "p eval('0'+'+0.1'*4581)"
ruby 1.8.8dev (2009-03-19) [i386-darwin9.6.0]
458.100000000036
$ ~/ruby-1.8.8-r23009/bin/ruby -ve "p eval('0'+'+0.1'*4582)"
ruby 1.8.8dev (2009-03-19) [i386-darwin9.6.0]
-e:1: can't modify frozen string (TypeError)
$ ~/ruby-1.8.8-r23009/bin/ruby -ve "p eval('0'+'+0.1'*5132)"
ruby 1.8.8dev (2009-03-19) [i386-darwin9.6.0]
-e:1: can't modify frozen string (TypeError)
$ ~/ruby-1.8.8-r23009/bin/ruby -ve "p eval('0'+'+0.1'*5133)"
ruby 1.8.8dev (2009-03-19) [i386-darwin9.6.0]
Segmentation fault

eval しなければ TypeError も SEGV も発生しないことは確認済です。

$ ~/ruby-1.8.8-r23009/bin/ruby -ve "'0'+'+0.1'*5133"
ruby 1.8.8dev (2009-03-19) [i386-darwin9.6.0]
-e:1: warning: useless use of + in void context
=end

Associated revisions

Revision a1b9ce96
Added by nobu (Nobuyoshi Nakada) over 10 years ago

  • eval.c (rb_eval): checks for interrupt, stack and finalizers too.
    [ruby-dev:38208], [Bug #1329]

  • eval.c (eval): replaces the message if frozen.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 4b4ac8ac
Added by shyouhei (Shyouhei Urabe) about 10 years ago

merge revision(s) 23096:
* eval.c (rb_eval): checks for interrupt, stack and finalizers too.
[ruby-dev:38208], [Bug #1329]
* eval.c (eval): replaces the message if frozen.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@23972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

#1

Updated by mrkn (Kenta Murata) over 10 years ago

=begin
古いリビジョンで試していたことに気付いて、最新のリビジョンでもう一度やってみました。
その結果、以下に示すように、症状は変わっていませんでした。

$ ~/ruby-1.8.8-r23088/bin/ruby -ve "p eval('0'+'+0.1'*4581)"
ruby 1.8.8dev (2009-03-28) [i386-darwin9.6.0]
458.100000000036
$ ~/ruby-1.8.8-r23088/bin/ruby -ve "p eval('0'+'+0.1'*4582)"
ruby 1.8.8dev (2009-03-28) [i386-darwin9.6.0]
-e:1: can't modify frozen string (TypeError)
$ ~/ruby-1.8.8-r23088/bin/ruby -ve "p eval('0'+'+0.1'*5132)"
ruby 1.8.8dev (2009-03-28) [i386-darwin9.6.0]
-e:1: can't modify frozen string (TypeError)
$ ~/ruby-1.8.8-r23088/bin/ruby -ve "p eval('0'+'+0.1'*5133)"
ruby 1.8.8dev (2009-03-28) [i386-darwin9.6.0]
Segmentation fault

$ ~/ruby-1.8.8-r23088/bin/ruby -ve "'0'+'+0.1'*5133"
ruby 1.8.8dev (2009-03-28) [i386-darwin9.6.0]
-e:1: warning: useless use of + in void context
=end

#2

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r23096.
=end

#3

Updated by shyouhei (Shyouhei Urabe) over 10 years ago

  • Status changed from Closed to Open
  • Assignee set to shyouhei (Shyouhei Urabe)

=begin

=end

#4

Updated by shyouhei (Shyouhei Urabe) about 10 years ago

  • Assignee changed from shyouhei (Shyouhei Urabe) to wyhaines (Kirk Haines)

=begin
1.8.6 also has this problem.
=end

#5

Updated by shyouhei (Shyouhei Urabe) almost 9 years ago

  • Status changed from Open to Assigned

=begin

=end

Also available in: Atom PDF