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

ruby-changes:28334

From: nagachika <ko1@a...>
Date: Sat, 20 Apr 2013 02:03:20 +0900 (JST)
Subject: [ruby-changes:28334] nagachika:r40386 (ruby_2_0_0): merge revision(s) 40102: [Backport #8234]

nagachika	2013-04-20 02:03:11 +0900 (Sat, 20 Apr 2013)

  New Revision: 40386

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

  Log:
    merge revision(s) 40102: [Backport #8234]
    
    * thread_pthread.c (ruby_init_stack): Avoid using uninitialized value.
      stackaddr and size are not set if get_stack() fails.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/thread_pthread.c
    branches/ruby_2_0_0/version.h

Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 40385)
+++ ruby_2_0_0/ChangeLog	(revision 40386)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sat Apr 20 01:56:32 2013  Yuki Yugui Sonoda  <yugui@g...>
+
+	* thread_pthread.c (ruby_init_stack): Avoid using uninitialized value.
+	  stackaddr and size are not set if get_stack() fails.
+
 Sat Apr 20 01:47:31 2013  Yuki Yugui Sonoda  <yugui@g...>
 
 	* thread_pthread.c: Fixes wrong scopes of #if USE_SLEEPY_TIMER_THREAD
Index: ruby_2_0_0/thread_pthread.c
===================================================================
--- ruby_2_0_0/thread_pthread.c	(revision 40385)
+++ ruby_2_0_0/thread_pthread.c	(revision 40386)
@@ -603,6 +603,23 @@ static struct { https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L603
 extern void *STACK_END_ADDRESS;
 #endif
 
+enum {
+    RUBY_STACK_SPACE_LIMIT = 1024 * 1024, /* 1024KB */
+    RUBY_STACK_SPACE_RATIO = 5
+};
+
+static size_t
+space_size(size_t stack_size)
+{
+    size_t space_size = stack_size / RUBY_STACK_SPACE_RATIO;
+    if (space_size > RUBY_STACK_SPACE_LIMIT) {
+	return RUBY_STACK_SPACE_LIMIT;
+    }
+    else {
+	return space_size;
+    }
+}
+
 #undef ruby_init_stack
 /* Set stack bottom of Ruby implementation.
  *
@@ -633,13 +650,21 @@ ruby_init_stack(volatile VALUE *addr https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L650
     }
 #endif
     {
-	size_t size = 0;
-	size_t space = 0;
+#if defined(PTHREAD_STACK_DEFAULT)
+# if PTHREAD_STACK_DEFAULT < RUBY_STACK_SPACE*5
+#  error "PTHREAD_STACK_DEFAULT is too small"
+# endif
+	size_t size = PTHREAD_STACK_DEFAULT;
+#else
+	size_t size = RUBY_VM_THREAD_VM_STACK_SIZE;
+#endif
+	size_t space = space_size(size);
 #if MAINSTACKADDR_AVAILABLE
 	void* stackaddr;
 	STACK_GROW_DIR_DETECTION;
-	get_stack(&stackaddr, &size);
-	space = STACK_DIR_UPPER((char *)addr - (char *)stackaddr, (char *)stackaddr - (char *)addr);
+	if (get_stack(&stackaddr, &size) == 0) {
+            space = STACK_DIR_UPPER((char *)addr - (char *)stackaddr, (char *)stackaddr - (char *)addr);
+        }
 	native_main_thread.stack_maxsize = size - space;
 #elif defined(HAVE_GETRLIMIT)
 	int pagesize = getpagesize();
@@ -846,23 +871,6 @@ use_cached_thread(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/thread_pthread.c#L871
     return result;
 }
 
-enum {
-    RUBY_STACK_SPACE_LIMIT = 1024 * 1024, /* 1024KB */
-    RUBY_STACK_SPACE_RATIO = 5
-};
-
-static size_t
-space_size(size_t stack_size)
-{
-    size_t space_size = stack_size / RUBY_STACK_SPACE_RATIO;
-    if (space_size > RUBY_STACK_SPACE_LIMIT) {
-	return RUBY_STACK_SPACE_LIMIT;
-    }
-    else {
-	return space_size;
-    }
-}
-
 static int
 native_thread_create(rb_thread_t *th)
 {
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 40385)
+++ ruby_2_0_0/version.h	(revision 40386)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2013-04-20"
-#define RUBY_PATCHLEVEL 151
+#define RUBY_PATCHLEVEL 152
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 4

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r40102


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

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