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

ruby-changes:49601

From: normal <ko1@a...>
Date: Tue, 9 Jan 2018 16:15:50 +0900 (JST)
Subject: [ruby-changes:49601] normal:r61716 (trunk): thread_pthread: more diagnostics around timer thread creation failures

normal	2018-01-09 16:15:44 +0900 (Tue, 09 Jan 2018)

  New Revision: 61716

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

  Log:
    thread_pthread: more diagnostics around timer thread creation failures
    
    However, I don't think EAGAIN on pthread_create can really
    be fixed in our code.  I suspect test machines are overloaded.

  Modified files:
    trunk/thread_pthread.c
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 61715)
+++ thread_pthread.c	(revision 61716)
@@ -1594,6 +1594,7 @@ static void https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1594
 rb_thread_create_timer_thread(void)
 {
     if (!timer_thread.created) {
+	size_t stack_size = 0;
 	int err;
 #ifdef HAVE_PTHREAD_ATTR_INIT
 	pthread_attr_t attr;
@@ -1621,10 +1622,14 @@ rb_thread_create_timer_thread(void) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1622
 		THREAD_DEBUG != 0
 #endif
 	    };
-	    size_t stack_size = PTHREAD_STACK_MIN; /* may be dynamic, get only once */
+	    stack_size = PTHREAD_STACK_MIN; /* may be dynamic, get only once */
 	    if (stack_size < min_size) stack_size = min_size;
 	    if (needs_more_stack) stack_size += BUFSIZ;
-	    pthread_attr_setstacksize(&attr, stack_size);
+	    err = pthread_attr_setstacksize(&attr, stack_size);
+	    if (err != 0) {
+		rb_bug("pthread_attr_setstacksize(.., %"PRIuSIZE") failed: %s",
+			stack_size, strerror(err));
+	    }
 	}
 # endif
 #endif
@@ -1653,6 +1658,7 @@ rb_thread_create_timer_thread(void) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1658
 	     * storage can cause small stack sizes to fail.  So lets hope the
 	     * default stack size is enough for them:
 	     */
+	    stack_size = 0;
 	    err = pthread_create(&timer_thread.id, NULL, thread_timer, &vm->gvl);
 	}
 #else
@@ -1661,6 +1667,12 @@ rb_thread_create_timer_thread(void) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1667
 	if (err != 0) {
 	    rb_warn("pthread_create failed for timer: %s, scheduling broken",
 		    strerror(err));
+	    if (stack_size) {
+		rb_warn("timer thread stack size: %"PRIuSIZE, stack_size);
+	    }
+	    else {
+		rb_warn("timer thread stack size: system default");
+	    }
 #if USE_SLEEPY_TIMER_THREAD
 	    CLOSE_INVALIDATE(normal[0]);
 	    CLOSE_INVALIDATE(normal[1]);

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

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