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

ruby-changes:5810

From: shyouhei <ko1@a...>
Date: Sun, 15 Jun 2008 23:18:49 +0900 (JST)
Subject: [ruby-changes:5810] Ruby:r17317 (ruby_1_8_5): merge revision(s) 16564:

shyouhei	2008-06-15 23:16:05 +0900 (Sun, 15 Jun 2008)

  New Revision: 17317

  Modified files:
    branches/ruby_1_8_5/ChangeLog
    branches/ruby_1_8_5/eval.c
    branches/ruby_1_8_5/marshal.c
    branches/ruby_1_8_5/version.h

  Log:
    merge revision(s) 16564:
    * marshal.c (reentrant_check): check reentrance via callcc.
      [ruby-dev:34802]


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/marshal.c?r1=17317&r2=17316&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/version.h?r1=17317&r2=17316&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/ChangeLog?r1=17317&r2=17316&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8_5/eval.c?r1=17317&r2=17316&diff_format=u

Index: ruby_1_8_5/ChangeLog
===================================================================
--- ruby_1_8_5/ChangeLog	(revision 17316)
+++ ruby_1_8_5/ChangeLog	(revision 17317)
@@ -3,7 +3,12 @@
 	* parse.y (top_local_setup): fixed memory leak bug based on a
 	  patch from Roger Pack <rogerpack2005 at gmail.com> in
 	  [ruby-core:16610].
+Sun Jun 15 23:15:35 2008  Yukihiro Matsumoto  <matz@r...>
 
+	* marshal.c (reentrant_check): check reentrance via callcc.
+	  [ruby-dev:34802]
+
+
 Sun Jun 15 23:08:29 2008  NAKAMURA Usaku  <usa@r...>
 
 	* sprintf.c (rb_f_sprintf): fixed SEGV on win32 with "% 0e" % 1.0/0.0.
Index: ruby_1_8_5/version.h
===================================================================
--- ruby_1_8_5/version.h	(revision 17316)
+++ ruby_1_8_5/version.h	(revision 17317)
@@ -2,7 +2,7 @@
 #define RUBY_RELEASE_DATE "2008-06-15"
 #define RUBY_VERSION_CODE 185
 #define RUBY_RELEASE_CODE 20080615
-#define RUBY_PATCHLEVEL 212
+#define RUBY_PATCHLEVEL 213
 
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 8
Index: ruby_1_8_5/marshal.c
===================================================================
--- ruby_1_8_5/marshal.c	(revision 17316)
+++ ruby_1_8_5/marshal.c	(revision 17317)
@@ -84,6 +84,16 @@
 static ID s_dump_data, s_load_data, s_alloc;
 static ID s_getc, s_read, s_write, s_binmode;
 
+static void
+reentrant_check(obj, sym)
+    VALUE obj;
+    ID sym;
+{
+    if (RBASIC(obj)->klass) {
+        rb_raise(rb_eRuntimeError, "%s reentered", rb_id2name(sym));
+    }
+}
+
 struct dump_arg {
     VALUE obj;
     VALUE str, dest;
@@ -505,6 +515,7 @@
 	    volatile VALUE v;
 
 	    v = rb_funcall(obj, s_mdump, 0, 0);
+	    reentrant_check(arg->str, s_mdump);
 	    w_class(TYPE_USRMARSHAL, obj, arg, Qfalse);
 	    w_object(v, arg, limit);
 	    if (ivtbl) w_ivar(0, &c_arg);
@@ -514,6 +525,7 @@
 	    VALUE v;
 
 	    v = rb_funcall(obj, s_dump, 1, INT2NUM(limit));
+	    reentrant_check(arg->str, s_dump);
 	    if (TYPE(v) != T_STRING) {
 		rb_raise(rb_eTypeError, "_dump() must return string");
 	    }
@@ -658,6 +670,7 @@
 			     rb_obj_classname(obj));
 		}
 		v = rb_funcall(obj, s_dump_data, 0);
+		reentrant_check(arg->str, s_dump_data);
 		w_class(TYPE_DATA, obj, arg, Qtrue);
 		w_object(v, arg, limit);
 	    }
@@ -690,11 +703,13 @@
 dump_ensure(arg)
     struct dump_arg *arg;
 {
+    if (RBASIC(arg->str)->klass) return; /* ignore reentrant */
     st_free_table(arg->symbols);
     st_free_table(arg->data);
     if (arg->taint) {
 	OBJ_TAINT(arg->str);
     }
+
     return 0;
 }
 
@@ -747,20 +762,21 @@
 	else port = a1;
     }
     arg.dest = 0;
+    arg.str = rb_str_buf_new(0);
+    RBASIC(arg.str)->klass = 0;
     if (!NIL_P(port)) {
 	if (!rb_respond_to(port, s_write)) {
 	  type_error:
 	    rb_raise(rb_eTypeError, "instance of IO needed");
 	}
-	arg.str = rb_str_buf_new(0);
 	arg.dest = port;
 	if (rb_respond_to(port, s_binmode)) {
 	    rb_funcall2(port, s_binmode, 0, 0);
+	    reentrant_check(arg.str, s_dump_data);
 	}
     }
     else {
-	port = rb_str_buf_new(0);
-	arg.str = port;
+	port = arg.str;
     }
 
     arg.symbols = st_init_numtable();
@@ -774,6 +790,7 @@
     w_byte(MARSHAL_MINOR, &arg);
 
     rb_ensure(dump, (VALUE)&c_arg, dump_ensure, (VALUE)&arg);
+    RBASIC(arg.str)->klass = rb_cString;
 
     return port;
 }
@@ -806,6 +823,7 @@
     else {
 	VALUE src = arg->src;
 	VALUE v = rb_funcall2(src, s_getc, 0, 0);
+	reentrant_check(arg->data, s_getc);
 	if (NIL_P(v)) rb_eof_error();
 	c = (unsigned char)FIX2INT(v);
     }
@@ -886,6 +904,7 @@
 	VALUE src = arg->src;
 	VALUE n = LONG2NUM(len);
 	str = rb_funcall2(src, s_read, 1, &n);
+	reentrant_check(arg->data, s_read);
 	if (NIL_P(str)) goto too_short;
 	StringValue(str);
 	if (RSTRING(str)->len != len) goto too_short;
@@ -1239,6 +1258,7 @@
 		*ivp = Qfalse;
 	    }
 	    v = rb_funcall(klass, s_load, 1, data);
+	    reentrant_check(arg->data, s_load);
 	    r_entry(v, arg);
 	}
         break;
@@ -1262,6 +1282,7 @@
 	    r_entry(v, arg);
 	    data = r_object(arg);
 	    rb_funcall(v, s_mload, 1, data);
+	    reentrant_check(arg->data, s_mload);
 	}
         break;
 
@@ -1288,6 +1309,7 @@
 		   warn = Qfalse;
 	       }
 	       v = rb_funcall(klass, s_alloc, 0);
+	       reentrant_check(arg->data, s_alloc);
            }
 	   else {
 	       v = rb_obj_alloc(klass);
@@ -1302,6 +1324,7 @@
                         rb_class2name(klass));
            }
            rb_funcall(v, s_load_data, 1, r_object0(arg, 0, 0, extmod));
+	   reentrant_check(arg->data, s_load_data);
        }
        break;
 
@@ -1344,7 +1367,9 @@
 	break;
     }
     if (proc) {
-	rb_funcall(proc, rb_intern("call"), 1, v);
+	ID s_call = 
+	rb_funcall(proc, s_call, 1, v);
+	reentrant_check(arg->data, s_call);
     }
     return v;
 }
@@ -1367,6 +1392,7 @@
 load_ensure(arg)
     struct load_arg *arg;
 {
+    if (RBASIC(arg->data)->klass) return; /* ignore reentrant */
     st_free_table(arg->symbols);
     return 0;
 }
@@ -1424,9 +1450,11 @@
 
     arg.symbols = st_init_numtable();
     arg.data   = rb_hash_new();
+    RBASIC(arg.data)->klass = 0;
     if (NIL_P(proc)) arg.proc = 0;
     else             arg.proc = proc;
     v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg);
+    RBASIC(arg.data)->klass = rb_cHash;
 
     return v;
 }
Index: ruby_1_8_5/eval.c
===================================================================
--- ruby_1_8_5/eval.c	(revision 17316)
+++ ruby_1_8_5/eval.c	(revision 17317)
@@ -5469,7 +5469,7 @@
     }
     POP_TAG();
     retval = prot_tag ? prot_tag->retval : Qnil;	/* save retval */
-    (*e_proc)(data2);
+	(*e_proc)(data2);
     if (prot_tag) return_value(retval);
     if (state) JUMP_TAG(state);
     return result;

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

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