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

ruby-changes:45561

From: nobu <ko1@a...>
Date: Wed, 15 Feb 2017 17:38:06 +0900 (JST)
Subject: [ruby-changes:45561] nobu:r57634 (trunk): marshal.c: revert r57631 partially

nobu	2017-02-15 17:38:01 +0900 (Wed, 15 Feb 2017)

  New Revision: 57634

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

  Log:
    marshal.c: revert r57631 partially
    
    * marshal.c (rb_marshal_dump_limited): do not free dump_arg, which
      may be dereferenced in check_dump_arg due to continuation, and
      get rid of dangling pointers.
    
    * marshal.c (rb_marshal_load_with_proc): ditto for load_arg.

  Modified files:
    trunk/marshal.c
    trunk/test/ruby/test_marshal.rb
Index: test/ruby/test_marshal.rb
===================================================================
--- test/ruby/test_marshal.rb	(revision 57633)
+++ test/ruby/test_marshal.rb	(revision 57634)
@@ -644,6 +644,9 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L644
     c = Bug9523.new
     assert_raise_with_message(RuntimeError, /Marshal\.dump reentered at marshal_dump/) do
       Marshal.dump(c)
+      GC.start
+      1000.times {"x"*1000}
+      GC.start
       c.cc.call
     end
   end
Index: marshal.c
===================================================================
--- marshal.c	(revision 57633)
+++ marshal.c	(revision 57634)
@@ -1053,8 +1053,8 @@ rb_marshal_dump_limited(VALUE obj, VALUE https://github.com/ruby/ruby/blob/trunk/marshal.c#L1053
 	rb_io_write(arg->dest, arg->str);
 	rb_str_resize(arg->str, 0);
     }
-    free_dump_arg(arg);
-    rb_gc_force_recycle(wrapper);
+    clear_dump_arg(arg);
+    RB_GC_GUARD(wrapper);
 
     return port;
 }
@@ -2084,8 +2084,8 @@ rb_marshal_load_with_proc(VALUE port, VA https://github.com/ruby/ruby/blob/trunk/marshal.c#L2084
 
     if (!NIL_P(proc)) arg->proc = proc;
     v = r_object(arg);
-    free_load_arg(arg);
-    rb_gc_force_recycle(wrapper);
+    clear_load_arg(arg);
+    RB_GC_GUARD(wrapper);
 
     return v;
 }

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

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