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

ruby-changes:48579

From: mame <ko1@a...>
Date: Tue, 7 Nov 2017 15:36:13 +0900 (JST)
Subject: [ruby-changes:48579] mame:r60694 (trunk): Symptomatic treatment for `rb_thread_terminate_all` freeze

mame	2017-11-07 15:36:07 +0900 (Tue, 07 Nov 2017)

  New Revision: 60694

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

  Log:
    Symptomatic treatment for `rb_thread_terminate_all` freeze
    
    Under uncertain condition, `rb_thread_terminate_all` gets stuck.  `make
    test-all TESTOPTS="test/ruby/test_gc.rb -n test_interrupt_in_finalizer`
    fails very rarely (only once every thousand runs).  This IS a bug, but
    seems difficult to fix it soon.
    
    This commit makes `rb_thread_terminate_all` wake up every one second,
    instead of waiting forever, which mitigates the unuseful freeze.
    This is not an essential solution for the bug, though.  I'll create a
    ticket with how to reproduce the original issue.

  Modified files:
    trunk/thread.c
Index: thread.c
===================================================================
--- thread.c	(revision 60693)
+++ thread.c	(revision 60694)
@@ -476,6 +476,8 @@ rb_threadptr_unlock_all_locking_mutexes( https://github.com/ruby/ruby/blob/trunk/thread.c#L476
     }
 }
 
+static struct timeval double2timeval(double d);
+
 void
 rb_thread_terminate_all(void)
 {
@@ -499,12 +501,13 @@ rb_thread_terminate_all(void) https://github.com/ruby/ruby/blob/trunk/thread.c#L501
 	terminate_all(vm, th);
 
 	while (vm_living_thread_num(vm) > 1) {
+	    struct timeval tv = double2timeval(1.0);
 	    /*
 	     * Thread exiting routine in thread_start_func_2 notify
 	     * me when the last sub-thread exit.
 	     */
 	    sleeping = 1;
-	    native_sleep(th, 0);
+	    native_sleep(th, &tv);
 	    RUBY_VM_CHECK_INTS_BLOCKING(ec);
 	    sleeping = 0;
 	}

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

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