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 | 9efe01cf291269f676fa3938994a478727ef60cf (patch) | |
tree | 4bb312c3636a1a18b30e1e737e937a2a424e5108 | |
parent | 67da441adb406d8149974eabaa6e52d1fd90cc59 (diff) | |
download | ruby-9efe01cf291269f676fa3938994a478727ef60cf.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
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | iseq.c | 5 | ||||
-rw-r--r-- | test/ruby/test_iseq.rb | 27 |
3 files changed, 33 insertions, 10 deletions
@@ -1,3 +1,8 @@ +Wed Jan 13 16:56:19 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * iseq.c (rb_iseq_mark): mark parent iseq to prevent dynamically + generated iseq by eval from GC. [ruby-core:72620] [Bug #11928] + Wed Jan 13 03:42:58 2016 Eric Wong <e@80x24.org> * class.c (Init_class_hierarchy): resolve name for rb_cObject ASAP @@ -9,12 +14,6 @@ Wed Jan 13 00:37:12 2016 Satoshi Ohmori <sachin21dev@gmail.com> * man/ruby.1: fix double word typo. [Fix GH-1194] -Wed Jan 13 00:16:47 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> - - * iseq.c (iseqw_mark): as wrapped iseq is isolated from the call - stack, it needs to take care of its parent and ancestors, so - that they do not become orphans. [ruby-core:72620] [Bug #11928] - Tue Jan 12 21:01:09 2016 Benoit Daloze <eregontp@gmail.com> * common.mk: update URL and name for the Ruby spec suite. @@ -113,6 +113,7 @@ rb_iseq_mark(const rb_iseq_t *iseq) rb_gc_mark(body->location.base_label); rb_gc_mark(body->location.path); RUBY_MARK_UNLESS_NULL(body->location.absolute_path); + RUBY_MARK_UNLESS_NULL((VALUE)body->parent_iseq); } if (FL_TEST(iseq, ISEQ_NOT_LOADED_YET)) { @@ -711,11 +712,7 @@ rb_iseq_coverage(const rb_iseq_t *iseq) static void iseqw_mark(void *ptr) { - const rb_iseq_t *iseq = ptr; rb_gc_mark((VALUE)ptr); - while ((iseq = iseq->body->parent_iseq) != NULL) { - rb_gc_mark((VALUE)iseq); - } } static size_t 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 |