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

ruby-changes:33345

From: nobu <ko1@a...>
Date: Wed, 26 Mar 2014 11:21:04 +0900 (JST)
Subject: [ruby-changes:33345] nobu:r45424 (trunk): marshal.c: undumpable hidden objects

nobu	2014-03-26 11:20:52 +0900 (Wed, 26 Mar 2014)

  New Revision: 45424

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

  Log:
    marshal.c: undumpable hidden objects
    
    * marshal.c (w_object): internal objects are not dumpable.
      [ruby-core:61677] [Bug #9674]

  Modified files:
    trunk/ChangeLog
    trunk/marshal.c
    trunk/test/thread/test_cv.rb
    trunk/test/thread/test_queue.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45423)
+++ ChangeLog	(revision 45424)
@@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Wed Mar 26 11:20:24 2014  Nobuyoshi Nakada  <nobu@r...>
+Wed Mar 26 11:20:50 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* marshal.c (w_object): internal objects are not dumpable.
+	  [ruby-core:61677] [Bug #9674]
 
 	* ext/thread/thread.c (undumpable): ConditionVariable and Queue
 	  are not dumpable.  [ruby-core:61677] [Bug #9674]
Index: marshal.c
===================================================================
--- marshal.c	(revision 45423)
+++ marshal.c	(revision 45424)
@@ -677,6 +677,11 @@ w_object(VALUE obj, struct dump_arg *arg https://github.com/ruby/ruby/blob/trunk/marshal.c#L677
     else {
 	VALUE v;
 
+	if (!RBASIC_CLASS(obj)) {
+	    rb_raise(rb_eTypeError, "can't dump internal %s",
+		     rb_builtin_type_name(BUILTIN_TYPE(obj)));
+	}
+
 	arg->infection |= (int)FL_TEST(obj, MARSHAL_INFECTION);
 
 	if (rb_obj_respond_to(obj, s_mdump, TRUE)) {
Index: test/thread/test_queue.rb
===================================================================
--- test/thread/test_queue.rb	(revision 45423)
+++ test/thread/test_queue.rb	(revision 45424)
@@ -216,6 +216,8 @@ class TestQueue < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/thread/test_queue.rb#L216
     end
   end
 
+  (DumpableQueue = Queue.dup).class_eval {remove_method :marshal_dump}
+
   def test_dump
     bug9674 = '[ruby-core:61677] [Bug #9674]'
     q = Queue.new
@@ -227,5 +229,10 @@ class TestQueue < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/thread/test_queue.rb#L229
     assert_raise_with_message(TypeError, /#{SizedQueue}/, bug9674) do
       Marshal.dump(sq)
     end
+
+    q = DumpableQueue.new
+    assert_raise_with_message(TypeError, /internal Array/, bug9674) do
+      Marshal.dump(q)
+    end
   end
 end
Index: test/thread/test_cv.rb
===================================================================
--- test/thread/test_cv.rb	(revision 45423)
+++ test/thread/test_cv.rb	(revision 45424)
@@ -197,11 +197,18 @@ INPUT https://github.com/ruby/ruby/blob/trunk/test/thread/test_cv.rb#L197
     end
   end
 
+  (DumpableCV = ConditionVariable.dup).class_eval {remove_method :marshal_dump}
+
   def test_dump
     bug9674 = '[ruby-core:61677] [Bug #9674]'
     condvar = ConditionVariable.new
     assert_raise_with_message(TypeError, /#{ConditionVariable}/, bug9674) do
       Marshal.dump(condvar)
     end
+
+    condvar = DumpableCV.new
+    assert_raise_with_message(TypeError, /internal Array/, bug9674) do
+      Marshal.dump(condvar)
+    end
   end
 end

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

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