* 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
This commit is contained in:
nobu 2016-01-13 07:56:51 +00:00
Родитель be4501bf3a
Коммит 22121544e1
3 изменённых файлов: 33 добавлений и 10 удалений

Просмотреть файл

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

5
iseq.c
Просмотреть файл

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

Просмотреть файл

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