From 62586a95d39a92d7c96b711919955b72c8ac5ecf Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 1 Jul 2016 18:59:06 +0000 Subject: [PATCH] merge revision(s) 55462: [Backport #11954] * vm.c (invoke_bmethod, invoke_block_from_c_0): revert r52104 partially to avoid "self has wrong type to call super in this context" errors. [ruby-core:72724] [Bug #11954] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@55560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 ++++++ test/ruby/test_objectspace.rb | 46 +++++++++++++++++++++++++++++++++++ version.h | 8 +++--- vm.c | 12 ++++----- 4 files changed, 63 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a4e2281f6..3e24ce7fd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Jul 2 03:33:28 2016 Shugo Maeda + + * vm.c (invoke_bmethod, invoke_block_from_c_0): revert r52104 + partially to avoid "self has wrong type to call super in this + context" errors. + [ruby-core:72724] [Bug #11954] + Mon Jun 20 02:38:29 2016 Nobuyoshi Nakada * lib/optparse.rb (OptionParser::Completion.candidate): get rid of diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb index ec561bc405..b2ab817fba 100644 --- a/test/ruby/test_objectspace.rb +++ b/test/ruby/test_objectspace.rb @@ -85,6 +85,52 @@ End } end + def test_finalizer_with_super + assert_in_out_err(["-e", <<-END], "", %w(:ok), []) + class A + def foo + end + end + + class B < A + def foo + 1.times { super } + end + end + + class C + module M + end + + FINALIZER = proc do + M.module_eval do + end + end + + def define_finalizer + ObjectSpace.define_finalizer(self, FINALIZER) + end + end + + class D + def foo + B.new.foo + end + end + + C::M.singleton_class.send :define_method, :module_eval do |src, id, line| + end + + GC.stress = true + 10.times do + C.new.define_finalizer + D.new.foo + end + + p :ok + END + end + def test_each_object klass = Class.new new_obj = klass.new diff --git a/version.h b/version.h index 9643b4b662..1baf03ef28 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.3.2" -#define RUBY_RELEASE_DATE "2016-06-20" -#define RUBY_PATCHLEVEL 135 +#define RUBY_RELEASE_DATE "2016-07-02" +#define RUBY_PATCHLEVEL 136 #define RUBY_RELEASE_YEAR 2016 -#define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 20 +#define RUBY_RELEASE_MONTH 7 +#define RUBY_RELEASE_DAY 2 #include "ruby/version.h" diff --git a/vm.c b/vm.c index 92e61fa632..f0957d1f38 100644 --- a/vm.c +++ b/vm.c @@ -922,15 +922,12 @@ invoke_block(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const rb_block_ } static VALUE -invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const rb_block_t *block, int type, int opt_pc) +invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const rb_block_t *block, const rb_callable_method_entry_t *me, int type, int opt_pc) { /* bmethod */ int arg_size = iseq->body->param.size; - const rb_callable_method_entry_t *me = th->passed_bmethod_me; VALUE ret; - th->passed_bmethod_me = NULL; - vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_BMETHOD, self, VM_ENVVAL_PREV_EP_PTR(block->ep), (VALUE)me, /* cref or method (TODO: can we ignore cref?) */ @@ -959,6 +956,9 @@ invoke_block_from_c_0(rb_thread_t *th, const rb_block_t *block, int i, opt_pc; int type = block_proc_is_lambda(block->proc) ? VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK; VALUE *sp = th->cfp->sp; + const rb_callable_method_entry_t *me = th->passed_bmethod_me; + + th->passed_bmethod_me = NULL; for (i=0; ipassed_bmethod_me == NULL) { + if (me == NULL) { return invoke_block(th, iseq, self, block, cref, type, opt_pc); } else { - return invoke_bmethod(th, iseq, self, block, type, opt_pc); + return invoke_bmethod(th, iseq, self, block, me, type, opt_pc); } }