From 66e42f4aa6285fdee33aef7137bee2636703b270 Mon Sep 17 00:00:00 2001 From: normal Date: Tue, 9 Jan 2018 07:15:44 +0000 Subject: 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_pthread.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/thread_pthread.c b/thread_pthread.c index 20b3a194ce..13d6dcb04d 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1594,6 +1594,7 @@ static void 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) 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) * 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) 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]); -- cgit v1.2.3