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

ruby-changes:38380

From: ktsj <ko1@a...>
Date: Sun, 10 May 2015 16:30:02 +0900 (JST)
Subject: [ruby-changes:38380] ktsj:r50461 (trunk): * proc.c (proc_binding): fix segmentation fault on marking phase.

ktsj	2015-05-10 16:29:44 +0900 (Sun, 10 May 2015)

  New Revision: 50461

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

  Log:
    * proc.c (proc_binding): fix segmentation fault on marking phase.
      envptr of newenvval should not be NULL.
    
      You can reproduce by
       make test-all TESTS='--gc-stress -n test_to_proc_binding ruby/test_method.rb'

  Modified files:
    trunk/ChangeLog
    trunk/proc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50460)
+++ ChangeLog	(revision 50461)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun May 10 16:23:58 2015  Kazuki Tsujimoto  <kazuki@c...>
+
+	* proc.c (proc_binding): fix segmentation fault on marking phase.
+	  envptr of newenvval should not be NULL.
+
+	  You can reproduce by
+	   make test-all TESTS='--gc-stress -n test_to_proc_binding ruby/test_method.rb'
+
 Sun May 10 12:41:18 2015  Masaki Matsushita <glass.saga@g...>
 
 	* ext/zlib/zlib.c (rb_gzreader_external_encoding):
Index: proc.c
===================================================================
--- proc.c	(revision 50460)
+++ proc.c	(revision 50461)
@@ -2510,15 +2510,16 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L2510
 	if (iseq && env->local_size < iseq->local_size) {
 	    int prev_local_size = env->local_size;
 	    int local_size = iseq->local_size;
-	    VALUE newenvval = TypedData_Wrap_Struct(RBASIC_CLASS(envval), RTYPEDDATA_TYPE(envval), 0);
-	    rb_env_t *newenv = xmalloc(sizeof(rb_env_t) + ((local_size + 1) * sizeof(VALUE)));
-	    RTYPEDDATA_DATA(newenvval) = newenv;
+	    rb_env_t *newenv;
+	    VALUE newenvval;
+	    newenv = xmalloc(sizeof(rb_env_t) + ((local_size + 1) * sizeof(VALUE)));
 	    newenv->env_size = local_size + 2;
 	    newenv->local_size = local_size;
 	    newenv->prev_envval = env->prev_envval;
 	    newenv->block = env->block;
 	    MEMCPY(newenv->env, env->env, VALUE, prev_local_size + 1);
 	    rb_mem_clear(newenv->env + prev_local_size + 1, local_size - prev_local_size);
+	    newenvval = TypedData_Wrap_Struct(RBASIC_CLASS(envval), RTYPEDDATA_TYPE(envval), newenv);
 	    newenv->env[local_size + 1] = newenvval;
 	    envval = newenvval;
 	}

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

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