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

ruby-changes:49607

From: nobu <ko1@a...>
Date: Tue, 9 Jan 2018 20:52:23 +0900 (JST)
Subject: [ruby-changes:49607] nobu:r61722 (trunk): thread_pthread.c: round stack size

nobu	2018-01-09 20:52:17 +0900 (Tue, 09 Jan 2018)

  New Revision: 61722

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

  Log:
    thread_pthread.c: round stack size
    
    * thread_pthread.c (rb_thread_create_timer_thread): round up
      additional stack size to PTHREAD_STACK_MIN, to get rid of
      EINVAL at pthread_attr_setstacksize().

  Modified files:
    trunk/thread_pthread.c
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 61721)
+++ thread_pthread.c	(revision 61722)
@@ -1596,6 +1596,7 @@ rb_thread_create_timer_thread(void) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1596
         }
 # ifdef PTHREAD_STACK_MIN
 	{
+	    size_t stack_min = PTHREAD_STACK_MIN; /* may be dynamic, get only once */
 	    const size_t min_size = (4096 * 4);
 	    /* Allocate the machine stack for the timer thread
 	     * at least 16KB (4 pages).  FreeBSD 8.2 AMD64 causes
@@ -1609,9 +1610,11 @@ rb_thread_create_timer_thread(void) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1610
 		THREAD_DEBUG != 0
 #endif
 	    };
-	    stack_size = PTHREAD_STACK_MIN; /* may be dynamic, get only once */
+	    stack_size = stack_min;
 	    if (stack_size < min_size) stack_size = min_size;
-	    if (needs_more_stack) stack_size += BUFSIZ;
+	    if (needs_more_stack) {
+		stack_size += +((BUFSIZ - 1) / stack_min + 1) * stack_min;
+	    }
 	    err = pthread_attr_setstacksize(&attr, stack_size);
 	    if (err != 0) {
 		rb_bug("pthread_attr_setstacksize(.., %"PRIuSIZE") failed: %s",

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

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