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

ruby-changes:39183

From: nobu <ko1@a...>
Date: Thu, 16 Jul 2015 14:34:34 +0900 (JST)
Subject: [ruby-changes:39183] nobu:r51264 (trunk): vm.c: fix mark with rewinding cfp

nobu	2015-07-16 14:34:27 +0900 (Thu, 16 Jul 2015)

  New Revision: 51264

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

  Log:
    vm.c: fix mark with rewinding cfp
    
    * vm.c (REWIND_CFP): keep the arguments region inside the valid
      value stack.  [ruby-core:69969] [Bug #11352]

  Modified files:
    trunk/ChangeLog
    trunk/vm.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51263)
+++ ChangeLog	(revision 51264)
@@ -1,10 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Thu Jul 16 14:18:37 2015  Nobuyoshi Nakada  <nobu@r...>
-
-	* vm.c (m_core_hash_merge_ptr): copy the arguments to the machine
-	  stack before rewinding the control frame pointer and leaving the
-	  arguments outside valid region of the value stack.
-	  [ruby-core:69969] [Bug #11352]
+Thu Jul 16 14:34:24 2015  Nobuyoshi Nakada  <nobu@r...>
 
+	* vm.c (REWIND_CFP): keep the arguments region inside the valid
+	  value stack.  [ruby-core:69969] [Bug #11352]
 
 Thu Jul 16 11:38:21 2015  Eric Wong  <e@8...>
 
Index: vm.c
===================================================================
--- vm.c	(revision 51263)
+++ vm.c	(revision 51264)
@@ -2297,7 +2297,11 @@ vm_define_method(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L2297
 
 #define REWIND_CFP(expr) do { \
     rb_thread_t *th__ = GET_THREAD(); \
-    th__->cfp++; expr; th__->cfp--; \
+    VALUE *const curr_sp = (th__->cfp++)->sp; \
+    VALUE *const saved_sp = th__->cfp->sp; \
+    th__->cfp->sp = curr_sp; \
+    expr; \
+    (th__->cfp--)->sp = saved_sp; \
 } while (0)
 
 static VALUE
@@ -2400,7 +2404,6 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L2404
 core_hash_merge_ary(VALUE hash, VALUE ary)
 {
     core_hash_merge(hash, RARRAY_LEN(ary), RARRAY_CONST_PTR(ary));
-    RB_GC_GUARD(ary);
     return hash;
 }
 
@@ -2408,14 +2411,8 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L2411
 m_core_hash_merge_ptr(int argc, VALUE *argv, VALUE recv)
 {
     VALUE hash = argv[0];
-    VALUE *args;
 
-    --argc; ++argv;
-    VM_ASSERT(argc <= 256);
-    args = ALLOCA_N(VALUE, argc);
-    MEMCPY(args, argv, VALUE, argc);
-    argv = args;
-    REWIND_CFP(core_hash_merge(hash, argc, argv));
+    REWIND_CFP(core_hash_merge(hash, argc-1, argv+1));
 
     return hash;
 }

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

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