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

ruby-changes:32647

From: nobu <ko1@a...>
Date: Tue, 28 Jan 2014 16:33:25 +0900 (JST)
Subject: [ruby-changes:32647] nobu:r44726 (trunk): thread_pthread.c: use get_stack

nobu	2014-01-28 16:33:20 +0900 (Tue, 28 Jan 2014)

  New Revision: 44726

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

  Log:
    thread_pthread.c: use get_stack
    
    * thread_pthread.c (ruby_init_stack, ruby_stack_overflowed_p):
      place get_stack above others to get stack boundary information.
      [ruby-core:60113] [Bug #9454]

  Modified files:
    trunk/ChangeLog
    trunk/thread_pthread.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44725)
+++ ChangeLog	(revision 44726)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jan 28 16:33:18 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread_pthread.c (ruby_init_stack, ruby_stack_overflowed_p):
+	  place get_stack above others to get stack boundary information.
+	  [ruby-core:60113] [Bug #9454]
+
+Tue Jan 28 16:31:13 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread_pthread.c (ruby_init_stack, ruby_stack_overflowed_p):
+	  place get_stack above others to get stack boundary information.
+	  [ruby-core:60113] [Bug #9454]
+
 Tue Jan 28 15:27:36 2014  NARUSE, Yui  <naruse@r...>
 
 	* thread_pthread.c: rlimit is only available on Linux.
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 44725)
+++ thread_pthread.c	(revision 44726)
@@ -661,6 +661,18 @@ ruby_init_stack(volatile VALUE *addr https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L661
     )
 {
     native_main_thread.id = pthread_self();
+#if MAINSTACKADDR_AVAILABLE
+    if (native_main_thread.stack_maxsize) return;
+    {
+	void* stackaddr;
+	size_t size;
+	if (get_main_stack(&stackaddr, &size) == 0) {
+	    native_main_thread.stack_maxsize = size;
+	    native_main_thread.stack_start = stackaddr;
+	    return;
+	}
+    }
+#endif
 #ifdef STACK_END_ADDRESS
     native_main_thread.stack_start = STACK_END_ADDRESS;
 #else
@@ -677,18 +689,6 @@ ruby_init_stack(volatile VALUE *addr https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L689
         native_main_thread.register_stack_start = (VALUE*)bsp;
     }
 #endif
-#if MAINSTACKADDR_AVAILABLE
-    if (native_main_thread.stack_maxsize) return;
-    {
-	void* stackaddr;
-	size_t size;
-	if (get_main_stack(&stackaddr, &size) == 0) {
-	    native_main_thread.stack_maxsize = size;
-	    native_main_thread.stack_start = stackaddr;
-	    return;
-	}
-    }
-#endif
     {
 #if defined(HAVE_GETRLIMIT)
 #if defined(PTHREAD_STACK_DEFAULT)
@@ -1560,23 +1560,24 @@ ruby_stack_overflowed_p(const rb_thread_ https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1560
     const size_t water_mark = 1024 * 1024;
     STACK_GROW_DIR_DETECTION;
 
-    if (th) {
-	size = th->machine.stack_maxsize;
-#if defined(HAVE_GETRLIMIT) && defined(__linux__) && MAINSTACKADDR_AVAILABLE
+#ifdef STACKADDR_AVAILABLE
+    if (get_stack(&base, &size) == 0) {
+# ifdef __APPLE__
 	if (pthread_equal(th->thread_id, native_main_thread.id)) {
 	    struct rlimit rlim;
 	    if (getrlimit(RLIMIT_STACK, &rlim) == 0 && rlim.rlim_cur > size) {
 		size = (size_t)rlim.rlim_cur;
 	    }
 	}
+# endif
+	base = (char *)base + STACK_DIR_UPPER(+size, -size);
+    }
+    else
 #endif
+    if (th) {
+	size = th->machine.stack_maxsize;
 	base = (char *)th->machine.stack_start - STACK_DIR_UPPER(0, size);
     }
-#ifdef STACKADDR_AVAILABLE
-    else if (get_stack(&base, &size) == 0) {
-	STACK_DIR_UPPER((void)(base = (char *)base + size), (void)0);
-    }
-#endif
     else {
 	return 0;
     }

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

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