diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-13 07:56:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-13 07:56:51 +0000 |
commit | 22121544e16ce6ad127712a79d6b69ef785c222e (patch) | |
tree | 4bb312c3636a1a18b30e1e737e937a2a424e5108 /test | |
parent | be4501bf3a8891533725288016e29ef7b63ea345 (diff) | |
download | ruby-22121544e16ce6ad127712a79d6b69ef785c222e.tar.gz |
iseq.c: mark parent iseq
* iseq.c (rb_iseq_mark): mark parent iseq to prevent dynamically
generated iseq by eval from GC. [ruby-core:72620] [Bug #11928]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_iseq.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index 4f7616a0db..7af8c1b11b 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -185,4 +185,31 @@ class TestISeq < Test::Unit::TestCase labels = body.select {|op, arg| op == :branchnil}.map {|op, arg| arg} assert_equal(1, labels.uniq.size) end + + def test_parent_iseq_mark + assert_separately([], <<-'end;') + ->{ + ->{ + ->{ + eval <<-EOS + class Segfault + define_method :segfault do + x = nil + GC.disable + 1000.times do |n| + n.times do + x = (foo rescue $!).local_variables + end + GC.start + end + x + end + end + EOS + }.call + }.call + }.call + at_exit { assert_equal([:n, :x], Segfault.new.segfault.sort) } + end; + end end |