ruby-changes:34382
From: ko1 <ko1@a...>
Date: Thu, 19 Jun 2014 18:17:37 +0900 (JST)
Subject: [ruby-changes:34382] ko1:r46463 (trunk): * vm_core.h: add VM_FRAME_MAGIC_RESCUE to recognize normal block or
ko1 2014-06-19 18:17:21 +0900 (Thu, 19 Jun 2014) New Revision: 46463 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46463 Log: * vm_core.h: add VM_FRAME_MAGIC_RESCUE to recognize normal block or rescue clause. * vm.c (vm_exec): use VM_FRAME_MAGIC_RESCUE on at rescue/ensure. * test/ruby/test_settracefunc.rb: should not invoke b_return at rescue clause. [Bug #9957] * vm_dump.c (control_frame_dump): check VM_FRAME_MAGIC_RESCUE. * vm_dump.c (vm_stack_dump_each): ditto. Modified files: trunk/ChangeLog trunk/test/ruby/test_settracefunc.rb trunk/vm.c trunk/vm_core.h trunk/vm_dump.c Index: ChangeLog =================================================================== --- ChangeLog (revision 46462) +++ ChangeLog (revision 46463) @@ -1,3 +1,18 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jun 19 18:14:47 2014 Koichi Sasada <ko1@a...> + + * vm_core.h: add VM_FRAME_MAGIC_RESCUE to recognize normal block or + rescue clause. + + * vm.c (vm_exec): use VM_FRAME_MAGIC_RESCUE on at rescue/ensure. + + * test/ruby/test_settracefunc.rb: should not invoke b_return at rescue + clause. + [Bug #9957] + + * vm_dump.c (control_frame_dump): check VM_FRAME_MAGIC_RESCUE. + + * vm_dump.c (vm_stack_dump_each): ditto. + Thu Jun 19 13:39:11 2014 Arne Brasseur <arne@a...> * proc.c (rb_method_curry): Implement Method#curry, which delegates Index: vm_core.h =================================================================== --- vm_core.h (revision 46462) +++ vm_core.h (revision 46463) @@ -756,7 +756,8 @@ enum vm_special_object_type { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L756 #define VM_FRAME_MAGIC_IFUNC 0x81 #define VM_FRAME_MAGIC_EVAL 0x91 #define VM_FRAME_MAGIC_LAMBDA 0xa1 -#define VM_FRAME_MAGIC_MASK_BITS 8 +#define VM_FRAME_MAGIC_RESCUE 0xb1 +#define VM_FRAME_MAGIC_MASK_BITS 8 #define VM_FRAME_MAGIC_MASK (~(~0<<VM_FRAME_MAGIC_MASK_BITS)) #define VM_FRAME_TYPE(cfp) ((cfp)->flag & VM_FRAME_MAGIC_MASK) Index: vm.c =================================================================== --- vm.c (revision 46462) +++ vm.c (revision 46463) @@ -1216,6 +1216,7 @@ vm_frametype_name(const rb_control_frame https://github.com/ruby/ruby/blob/trunk/vm.c#L1216 case VM_FRAME_MAGIC_IFUNC: return "ifunc"; case VM_FRAME_MAGIC_EVAL: return "eval"; case VM_FRAME_MAGIC_LAMBDA: return "lambda"; + case VM_FRAME_MAGIC_RESCUE: return "rescue"; default: rb_bug("unknown frame"); } @@ -1520,7 +1521,7 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L1521 /* push block frame */ cfp->sp[0] = err; - vm_push_frame(th, catch_iseq, VM_FRAME_MAGIC_BLOCK, + vm_push_frame(th, catch_iseq, VM_FRAME_MAGIC_RESCUE, cfp->self, cfp->klass, VM_ENVVAL_PREV_EP_PTR(cfp->ep), catch_iseq->iseq_encoded, Index: vm_dump.c =================================================================== --- vm_dump.c (revision 46462) +++ vm_dump.c (revision 46463) @@ -73,6 +73,9 @@ control_frame_dump(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L73 case VM_FRAME_MAGIC_EVAL: magic = "EVAL"; break; + case VM_FRAME_MAGIC_RESCUE: + magic = "RESCUE"; + break; case 0: magic = "------"; break; @@ -268,15 +271,17 @@ vm_stack_dump_each(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L271 /* stack trace header */ - if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_METHOD || - VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_TOP || + if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_METHOD|| + VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_TOP || VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_BLOCK || VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CLASS || - VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_PROC || - VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_LAMBDA || + VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_PROC || + VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_LAMBDA|| VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC || VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_IFUNC || - VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_EVAL) { + VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_EVAL || + VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_RESCUE) + { VALUE *ptr = ep - local_size; Index: test/ruby/test_settracefunc.rb =================================================================== --- test/ruby/test_settracefunc.rb (revision 46462) +++ test/ruby/test_settracefunc.rb (revision 46463) @@ -1202,4 +1202,40 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L1202 raise if stack != [:p, :hash, :inspect] }, '[Bug #9940]' end + + def method_test_rescue_should_not_cause_b_return + begin + raise + rescue + return + end + end + + def method_test_ensure_should_not_cause_b_return + begin + raise + ensure + return + end + end + + def test_rescue_and_ensure_should_not_cause_b_return + curr_thread = Thread.current + trace = TracePoint.new(:b_call, :b_return){ + next if curr_thread != Thread.current + flunk("Should not reach here because there is no block.") + } + + begin + trace.enable + method_test_rescue_should_not_cause_b_return + begin + method_test_ensure_should_not_cause_b_return + rescue + # ignore + end + ensure + trace.disable + end + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/