From 3e557a979ecc2c9a43ffa3bbdb8fc2a6c5cfca61 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 6 Mar 2015 01:31:03 +0000 Subject: vm_eval.c: next super class from the original * vm_eval.c (vm_call_super): search next super class from the original class, to get rid of infinite recursion with prepending. a patch by Seiei Higa at [ruby-core:68434]. [ruby-core:68093] [Bug #10847] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ test/ruby/test_module.rb | 11 +++++++++++ vm_eval.c | 3 ++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 25034759a7..e9c82f2f03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Mar 6 10:31:00 2015 Nobuyoshi Nakada + + * vm_eval.c (vm_call_super): search next super class from the + original class, to get rid of infinite recursion with + prepending. a patch by Seiei Higa at + [ruby-core:68434]. [ruby-core:68093] [Bug #10847] + Fri Mar 6 08:45:26 2015 Marc-Andre Lafortune * lib/matrix.rb: Add Vector#round. Patch by Jordan Stephens. diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index d014e8cb05..f1ca0b7cc1 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1748,6 +1748,17 @@ class TestModule < Test::Unit::TestCase assert_equal([m, c2, m, c1], c2.ancestors[0, 4], "should accesisble prepended module in superclass") end + def test_prepend_call_super + assert_separately([], <<-'end;') #do + bug10847 = '[ruby-core:68093] [Bug #10847]' + module M; end + Float.prepend M + assert_nothing_raised(SystemStackError, bug10847) do + 0.3.numerator + end + end; + end + def test_class_variables m = Module.new m.class_variable_set(:@@foo, 1) diff --git a/vm_eval.c b/vm_eval.c index 6eeee5f02e..4039b6c9f2 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -273,7 +273,8 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv) rb_bug("vm_call_super: should not be reached"); } - klass = RCLASS_SUPER(cfp->klass); + klass = RCLASS_ORIGIN(cfp->klass); + klass = RCLASS_SUPER(klass); id = cfp->me->def->original_id; me = rb_method_entry(klass, id, &klass); if (!me) { -- cgit v1.2.3