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

ruby-changes:45881

From: naruse <ko1@a...>
Date: Mon, 13 Mar 2017 16:30:35 +0900 (JST)
Subject: [ruby-changes:45881] naruse:r57954 (ruby_2_4): merge revision(s) 57410, 57619, 57621, 57631, 57634: [Backport #13150]

naruse	2017-03-13 16:30:30 +0900 (Mon, 13 Mar 2017)

  New Revision: 57954

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

  Log:
    merge revision(s) 57410,57619,57621,57631,57634: [Backport #13150]
    
    Prevent GC by volatile [Bug #13150]
    
    test/ruby/test_marshal.rb test_context_switch (load) and test_gc (dump)
    are failed on FreeBSD 10.3 and gcc7 (FreeBSD Ports Collection) 7.0.0
    20170115 (experimental); RB_GC_GUARD looks not worked well.
    ruby.h: RB_GC_GUARD stronger than gcc7
    
    * include/ruby/ruby.h (RB_GC_GUARD): prevent guarded pointer from
      optimization by using as an input to inline asm.
    ruby.h: remove comment
    
    * include/ruby/ruby.h (RB_GC_GUARD): remove comment unsupported by
      Solaris AS.
    marshal.c: use hidden objects to allow recycling
    
    Hidden objects (klass == 0) are not visible to Ruby code invoked
    from other threads or signal handlers, so they can never be
    accessed from other contexts.  This makes it safe to call
    rb_gc_force_recycle on the object slot after releasing malloc
    memory.
    
    * marshal.c (rb_marshal_dump_limited): hide dump_arg and recycle when done
      (rb_marshal_load_with_proc): hide load_arg and recycle when done
      [ruby-core:79518]
    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 directories:
    branches/ruby_2_4/
  Modified files:
    branches/ruby_2_4/include/ruby/ruby.h
    branches/ruby_2_4/marshal.c
    branches/ruby_2_4/test/ruby/test_marshal.rb
    branches/ruby_2_4/version.h
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 57953)
+++ ruby_2_4/version.h	(revision 57954)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.0"
 #define RUBY_RELEASE_DATE "2017-03-13"
-#define RUBY_PATCHLEVEL 99
+#define RUBY_PATCHLEVEL 100
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_4/marshal.c
===================================================================
--- ruby_2_4/marshal.c	(revision 57953)
+++ ruby_2_4/marshal.c	(revision 57954)
@@ -1026,7 +1026,7 @@ rb_marshal_dump_limited(VALUE obj, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_4/marshal.c#L1026
     struct dump_arg *arg;
     VALUE wrapper; /* used to avoid memory leak in case of exception */
 
-    wrapper = TypedData_Make_Struct(rb_cData, struct dump_arg, &dump_arg_data, arg);
+    wrapper = TypedData_Make_Struct(0, struct dump_arg, &dump_arg_data, arg);
     arg->dest = 0;
     arg->symbols = st_init_numtable();
     arg->data    = rb_init_identtable();
@@ -2053,7 +2053,7 @@ rb_marshal_load_with_proc(VALUE port, VA https://github.com/ruby/ruby/blob/trunk/ruby_2_4/marshal.c#L2053
     else {
 	io_needed();
     }
-    wrapper = TypedData_Make_Struct(rb_cData, struct load_arg, &load_arg_data, arg);
+    wrapper = TypedData_Make_Struct(0, struct load_arg, &load_arg_data, arg);
     arg->infection = infection;
     arg->src = port;
     arg->offset = 0;
Index: ruby_2_4/test/ruby/test_marshal.rb
===================================================================
--- ruby_2_4/test/ruby/test_marshal.rb	(revision 57953)
+++ ruby_2_4/test/ruby/test_marshal.rb	(revision 57954)
@@ -644,6 +644,9 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/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: ruby_2_4/include/ruby/ruby.h
===================================================================
--- ruby_2_4/include/ruby/ruby.h	(revision 57953)
+++ ruby_2_4/include/ruby/ruby.h	(revision 57954)
@@ -536,7 +536,11 @@ static inline int rb_type(VALUE obj); https://github.com/ruby/ruby/blob/trunk/ruby_2_4/include/ruby/ruby.h#L536
 
 #ifdef __GNUC__
 #define RB_GC_GUARD(v) \
-    (*__extension__ ({volatile VALUE *rb_gc_guarded_ptr = &(v); rb_gc_guarded_ptr;}))
+    (*__extension__ ({ \
+	volatile VALUE *rb_gc_guarded_ptr = &(v); \
+	__asm__("" : : "m"(rb_gc_guarded_ptr)); \
+	rb_gc_guarded_ptr; \
+    }))
 #elif defined _MSC_VER
 #pragma optimize("", off)
 static inline volatile VALUE *rb_gc_guarded_ptr(volatile VALUE *ptr) {return ptr;}

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57410,57619,57621,57631,57634


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

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