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

ruby-changes:37635

From: naruse <ko1@a...>
Date: Tue, 24 Feb 2015 15:40:08 +0900 (JST)
Subject: [ruby-changes:37635] naruse:r49716 (ruby_2_2): merge revision(s) 49474, 49541, 49545, 49684: [Backport #10768]

naruse	2015-02-24 15:39:50 +0900 (Tue, 24 Feb 2015)

  New Revision: 49716

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

  Log:
    merge revision(s) 49474,49541,49545,49684: [Backport #10768]
    
    * gc.c (rb_objspace_free): cause rb_bug if lazy sweep is in progress
      during rb_objspace_free. Adds extra protection for r46340.
      Patch by Vicent Marti. [Bug #10768] [ruby-core:67734]
    
    * gc.c (rb_objspace_call_finalizer): Ensure GC is completed after
      finalizers have run. We already call gc_rest() before invoking
      finalizers, but finalizer can allocate new objects and start new GC
      cycle, so we call gc_rest() again after finalizers are complete.
    
    * gc.c (rb_objspace_call_finalizer): control GC execution during
      force firnalizations at the end of interpreter process.
      [Bug #10768]
      1) Prohibit incremental GC while running Ruby-level finalizers
         to avoid any danger.
      2) Prohibit GC while invoking T_DATA/T_FILE data structure
         because these operations break object relations consistency.
      This patch can introduce another memory consuming issue because
      Ruby-level finalizers can run after (2), GC is disabled.
      However, basically object consistency was broken at (2) as I
      described above. So that running Ruby-level finalizers contains
      danger originally. Because of this point, I need to suggest to
      remove these 3 lines (invoking remaining finalizers). And add a
      rule to add that finalizers should not add new finalizers, or
      say there is no guarantee to invoke finalizers that added by
      another finalizer.

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/gc.c
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 49715)
+++ ruby_2_2/ChangeLog	(revision 49716)
@@ -1,3 +1,34 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Tue Feb 24 14:00:46 2015  Koichi Sasada  <ko1@a...>
+
+	* gc.c (rb_objspace_call_finalizer): control GC execution during
+	  force firnalizations at the end of interpreter process.
+	  [Bug #10768]
+
+	  1) Prohibit incremental GC while running Ruby-level finalizers
+	     to avoid any danger.
+	  2) Prohibit GC while invoking T_DATA/T_FILE data structure
+	     because these operations break object relations consistency.
+
+	  This patch can introduce another memory consuming issue because
+	  Ruby-level finalizers can run after (2), GC is disabled.
+	  However, basically object consistency was broken at (2) as I
+	  described above. So that running Ruby-level finalizers contains
+	  danger originally. Because of this point, I need to suggest to
+	  remove these 3 lines (invoking remaining finalizers). And add a
+	  rule to add that finalizers should not add new finalizers, or
+	  say there is no guarantee to invoke finalizers that added by
+	  another finalizer.
+
+Tue Feb 24 14:00:46 2015  Aman Gupta <ruby@t...>
+
+	* gc.c (rb_objspace_free): cause rb_bug if lazy sweep is in progress
+	  during rb_objspace_free. Adds extra protection for r46340.
+	  Patch by Vicent Marti. [Bug #10768] [ruby-core:67734]
+	* gc.c (rb_objspace_call_finalizer): Ensure GC is completed after
+	  finalizers have run. We already call gc_rest() before invoking
+	  finalizers, but finalizer can allocate new objects and start new GC
+	  cycle, so we call gc_rest() again after finalizers are complete.
+
 Tue Feb 24 10:30:59 2015  Kazuki Tsujimoto  <kazuki@c...>
 
 	* vm_insnhelper.c (rb_vm_rewrite_cref_stack): copy nd_refinements
Index: ruby_2_2/gc.c
===================================================================
--- ruby_2_2/gc.c	(revision 49715)
+++ ruby_2_2/gc.c	(revision 49716)
@@ -1209,6 +1209,9 @@ static void heap_page_free(rb_objspace_t https://github.com/ruby/ruby/blob/trunk/ruby_2_2/gc.c#L1209
 void
 rb_objspace_free(rb_objspace_t *objspace)
 {
+    if (is_lazy_sweeping(heap_eden))
+	rb_bug("lazy sweeping underway when freeing object space");
+
     if (objspace->profile.records) {
 	free(objspace->profile.records);
 	objspace->profile.records = 0;
@@ -2563,6 +2566,10 @@ rb_objspace_call_finalizer(rb_objspace_t https://github.com/ruby/ruby/blob/trunk/ruby_2_2/gc.c#L2566
     finalize_deferred(objspace);
     assert(heap_pages_deferred_final == 0);
 
+    gc_rest(objspace);
+    /* prohibit incremental GC */
+    objspace->flags.dont_incremental = 1;
+
     /* force to run finalizer */
     while (finalizer_table->num_entries) {
 	struct force_finalize_list *list = 0;
@@ -2577,10 +2584,13 @@ rb_objspace_call_finalizer(rb_objspace_t https://github.com/ruby/ruby/blob/trunk/ruby_2_2/gc.c#L2584
 	}
     }
 
-    /* finalizers are part of garbage collection */
+    /* prohibit GC because force T_DATA finalizers can break an object graph consistency */
+    dont_gc = 1;
+
+    /* running data/file finalizers are part of garbage collection */
     gc_enter(objspace, "rb_objspace_call_finalizer");
 
-    /* run data object's finalizers */
+    /* run data/file object's finalizers */
     for (i = 0; i < heap_allocated_pages; i++) {
 	p = heap_pages_sorted[i]->start; pend = p + heap_pages_sorted[i]->total_slots;
 	while (p < pend) {
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 49715)
+++ ruby_2_2/version.h	(revision 49716)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.0"
 #define RUBY_RELEASE_DATE "2015-02-24"
-#define RUBY_PATCHLEVEL 78
+#define RUBY_PATCHLEVEL 79
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 2

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r49474,49541,49545,49684


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

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