ruby-changes:41440
From: nobu <ko1@a...>
Date: Wed, 13 Jan 2016 00:16:55 +0900 (JST)
Subject: [ruby-changes:41440] nobu:r53514 (trunk): iseq.c: mark parents of wrapped iseq
nobu 2016-01-13 00:17:19 +0900 (Wed, 13 Jan 2016) New Revision: 53514 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53514 Log: iseq.c: mark parents of wrapped iseq * 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] Added files: trunk/test/ruby/bug-11928.rb Modified files: trunk/ChangeLog trunk/iseq.c trunk/test/ruby/test_exception.rb Index: test/ruby/bug-11928.rb =================================================================== --- test/ruby/bug-11928.rb (revision 0) +++ test/ruby/bug-11928.rb (revision 53514) @@ -0,0 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/bug-11928.rb#L1 +class Segfault + at_exit { Segfault.new.segfault } + + define_method 'segfault' do + n = 11928 + v = nil + i = 0 + while i < n + i += 1 + v = (foo rescue $!).local_variables + end + assert_equal(%i[i n v], v.sort) + end +end Property changes on: test/ruby/bug-11928.rb ___________________________________________________________________ Added: svn:eol-style + LF Index: test/ruby/test_exception.rb =================================================================== --- test/ruby/test_exception.rb (revision 53513) +++ test/ruby/test_exception.rb (revision 53514) @@ -701,6 +701,12 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L701 assert_equal(%i[a b c d e f g], e.local_variables.sort) end + def test_name_error_info_parent_iseq_mark + assert_separately(['-', File.join(__dir__, 'bug-11928.rb')], <<-'end;') + -> {require ARGV[0]}.call + end; + end + def test_output_string_encoding # "\x82\xa0" in cp932 is "\u3042" (Japanese hiragana 'a') # change $stderr to force calling rb_io_write() instead of fwrite() Index: iseq.c =================================================================== --- iseq.c (revision 53513) +++ iseq.c (revision 53514) @@ -711,7 +711,11 @@ rb_iseq_coverage(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L711 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 Index: ChangeLog =================================================================== --- ChangeLog (revision 53513) +++ ChangeLog (revision 53514) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Jan 13 00:16:47 2016 Nobuyoshi Nakada <nobu@r...> + + * 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@g...> * common.mk: update URL and name for the Ruby spec suite. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/