[前][次][番号順一覧][スレッド一覧]

ruby-changes:50541

From: nobu <ko1@a...>
Date: Wed, 7 Mar 2018 00:14:28 +0900 (JST)
Subject: [ruby-changes:50541] nobu:r62680 (trunk): vm_insnhelper.c: blockparamproxy in rescue

nobu	2018-03-07 00:14:22 +0900 (Wed, 07 Mar 2018)

  New Revision: 62680

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62680

  Log:
    vm_insnhelper.c: blockparamproxy in rescue
    
    * vm_insnhelper.c (vm_call_opt_block_call): get block handler from
      the method local frame.  fix segfault at calling the proxy in
      rescue.  http://twitter.com/wannabe53/status/970955247626567680

  Modified files:
    trunk/test/ruby/test_optimization.rb
    trunk/vm_insnhelper.c
Index: test/ruby/test_optimization.rb
===================================================================
--- test/ruby/test_optimization.rb	(revision 62679)
+++ test/ruby/test_optimization.rb	(revision 62680)
@@ -741,4 +741,16 @@ class TestRubyOptimization < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_optimization.rb#L741
     end
     assert_equal(:ok, obj.a())
   end
+
+  def test_blockparam_in_rescue
+    obj = Object.new
+    def obj.foo(&b)
+      raise
+    rescue
+      b.call
+    end
+    result = nil
+    assert_equal(42, obj.foo {result = 42})
+    assert_equal(42, result)
+  end
 end
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 62679)
+++ vm_insnhelper.c	(revision 62680)
@@ -2083,7 +2083,7 @@ vm_call_opt_call(rb_execution_context_t https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2083
 static VALUE
 vm_call_opt_block_call(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
 {
-    VALUE block_handler = VM_ENV_BLOCK_HANDLER(reg_cfp->ep);
+    VALUE block_handler = VM_ENV_BLOCK_HANDLER(VM_CF_LEP(reg_cfp));
 
     if (BASIC_OP_UNREDEFINED_P(BOP_CALL, PROC_REDEFINED_OP_FLAG)) {
 	return vm_invoke_block_opt_call(ec, reg_cfp, calling, ci, block_handler);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]