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

ruby-changes:31495

From: ko1 <ko1@a...>
Date: Fri, 8 Nov 2013 03:03:16 +0900 (JST)
Subject: [ruby-changes:31495] ko1:r43574 (trunk): * gc.c (vm_malloc_increase): check GVL before gc_rest_sweep().

ko1	2013-11-08 03:03:12 +0900 (Fri, 08 Nov 2013)

  New Revision: 43574

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

  Log:
    * gc.c (vm_malloc_increase): check GVL before gc_rest_sweep().
      vm_malloc_increase() can be called without GVL.
      However, gc_rest_sweep() assumes acquiring GVL.
      To avoid this problem, check GVL before gc_rest_sweep().
      [Bug #9090]
      This workaround introduces possibility to set malloc_limit as
      wrong value (*1). However, this may be rare case. So I commit it.
      *1: Without rest_sweep() here, gc_rest_sweep() can decrease
          malloc_increase due to ruby_sized_xfree().

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43573)
+++ ChangeLog	(revision 43574)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Nov  8 02:44:29 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c (vm_malloc_increase): check GVL before gc_rest_sweep().
+	  vm_malloc_increase() can be called without GVL.
+	  However, gc_rest_sweep() assumes acquiring GVL.
+	  To avoid this problem, check GVL before gc_rest_sweep().
+	  [Bug #9090]
+
+	  This workaround introduces possibility to set malloc_limit as
+	  wrong value (*1). However, this may be rare case. So I commit it.
+
+	  *1: Without rest_sweep() here, gc_rest_sweep() can decrease
+	      malloc_increase due to ruby_sized_xfree().
+
 Fri Nov  8 02:50:25 2013  Zachary Scott  <e@z...>
 
 	* lib/securerandom.rb: [DOC] specify arguments passed to ::random_bytes
Index: gc.c
===================================================================
--- gc.c	(revision 43573)
+++ gc.c	(revision 43574)
@@ -5446,7 +5446,7 @@ vm_malloc_increase(rb_objspace_t *objspa https://github.com/ruby/ruby/blob/trunk/gc.c#L5446
 	else {
 	  retry:
 	    if (malloc_increase > malloc_limit) {
-		if (is_lazy_sweeping(heap_eden)) {
+		if (ruby_thread_has_gvl_p() && is_lazy_sweeping(heap_eden)) {
 		    gc_rest_sweep(objspace); /* rest_sweep can reduce malloc_increase */
 		    goto retry;
 		}

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

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