1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2016-03-29 14:15:17 +00:00
parent 6b2f77a844
commit d3c05ae77c
6 changed files with 54 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Tue Mar 29 23:10:47 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]
Tue Mar 29 22:56:44 2016 Eric Wong <e@80x24.org>
* lib/resolv.rb (Resolv::IPv6.create): avoid modifying frozen

1
iseq.c
View file

@ -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)) {

14
test/ruby/bug-11928.rb Normal file
View file

@ -0,0 +1,14 @@
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

View file

@ -701,6 +701,12 @@ end.join
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()

View file

@ -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

View file

@ -1,6 +1,6 @@
#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