ruby-changes:42331
From: naruse <ko1@a...>
Date: Tue, 29 Mar 2016 23:15:21 +0900 (JST)
Subject: [ruby-changes:42331] naruse:r54405 (ruby_2_3): merge revision(s) 53514, 53524: [Backport #11928]
naruse 2016-03-29 23:15:17 +0900 (Tue, 29 Mar 2016) New Revision: 54405 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54405 Log: merge revision(s) 53514,53524: [Backport #11928] * 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] * iseq.c (rb_iseq_mark): mark parent iseq to prevent dynamically generated iseq by eval from GC. [ruby-core:72620] [Bug #11928] Added files: branches/ruby_2_3/test/ruby/bug-11928.rb Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/iseq.c branches/ruby_2_3/test/ruby/test_exception.rb branches/ruby_2_3/test/ruby/test_iseq.rb branches/ruby_2_3/version.h Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 54404) +++ ruby_2_3/version.h (revision 54405) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.0" #define RUBY_RELEASE_DATE "2016-03-29" -#define RUBY_PATCHLEVEL 53 +#define RUBY_PATCHLEVEL 54 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_3/iseq.c =================================================================== --- ruby_2_3/iseq.c (revision 54404) +++ ruby_2_3/iseq.c (revision 54405) @@ -113,6 +113,7 @@ rb_iseq_mark(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/iseq.c#L113 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)) { Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 54404) +++ ruby_2_3/ChangeLog (revision 54405) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Tue Mar 29 23:10:47 2016 Nobuyoshi Nakada <nobu@r...> + + * iseq.c (rb_iseq_mark): mark parent iseq to prevent dynamically + generated iseq by eval from GC. [ruby-core:72620] [Bug #11928] + Tue Mar 29 22:56:44 2016 Eric Wong <e@8...> * lib/resolv.rb (Resolv::IPv6.create): avoid modifying frozen Index: ruby_2_3/test/ruby/test_exception.rb =================================================================== --- ruby_2_3/test/ruby/test_exception.rb (revision 54404) +++ ruby_2_3/test/ruby/test_exception.rb (revision 54405) @@ -701,6 +701,12 @@ end.join https://github.com/ruby/ruby/blob/trunk/ruby_2_3/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: ruby_2_3/test/ruby/bug-11928.rb =================================================================== --- ruby_2_3/test/ruby/bug-11928.rb (revision 0) +++ ruby_2_3/test/ruby/bug-11928.rb (revision 54405) @@ -0,0 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/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: ruby_2_3/test/ruby/bug-11928.rb ___________________________________________________________________ Added: svn:eol-style + LF Index: ruby_2_3/test/ruby/test_iseq.rb =================================================================== --- ruby_2_3/test/ruby/test_iseq.rb (revision 54404) +++ ruby_2_3/test/ruby/test_iseq.rb (revision 54405) @@ -185,4 +185,31 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_iseq.rb#L185 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 Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r53514,53524 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/