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

ruby-changes:20347

From: naruse <ko1@a...>
Date: Mon, 4 Jul 2011 07:16:11 +0900 (JST)
Subject: [ruby-changes:20347] naruse:r32395 (trunk): * thread_pthread.c (get_stack): the return address of get_stack

naruse	2011-07-04 07:16:02 +0900 (Mon, 04 Jul 2011)

  New Revision: 32395

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

  Log:
    * thread_pthread.c (get_stack): the return address of get_stack
      must be the highest address of the current thread's stack.

  Modified files:
    trunk/ChangeLog
    trunk/thread_pthread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32394)
+++ ChangeLog	(revision 32395)
@@ -1,3 +1,8 @@
+Mon Jul  4 07:14:12 2011  NARUSE, Yui  <naruse@r...>
+
+	* thread_pthread.c (get_stack): the return address of get_stack
+	  must be the highest address of the current thread's stack.
+
 Mon Jul  4 06:37:22 2011  Koichi Sasada  <ko1@a...>
 
 	* include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 32394)
+++ thread_pthread.c	(revision 32395)
@@ -453,6 +453,9 @@
 #endif
 
 #ifdef STACKADDR_AVAILABLE
+/*
+ * Get the highest address and size of current thread's stack
+ */
 static int
 get_stack(void **addr, size_t *size)
 {
@@ -478,6 +481,7 @@
     CHECK_ERR(pthread_attr_get_np(pthread_self(), &attr));
     CHECK_ERR(pthread_attr_getstackaddr(&attr, addr));
     CHECK_ERR(pthread_attr_getstacksize(&attr, size));
+    *addr = (char *)*addr + *size;
 # else /* MacOS X */
     pthread_t th = pthread_self();
     *addr = pthread_get_stackaddr_np(th);
@@ -489,14 +493,14 @@
     pthread_attr_destroy(&attr);
 #elif defined HAVE_THR_STKSEGMENT || defined HAVE_PTHREAD_STACKSEG_NP
     stack_t stk;
-# if defined HAVE_THR_STKSEGMENT
+# if defined HAVE_THR_STKSEGMENT /* Solaris */
     CHECK_ERR(thr_stksegment(&stk));
-# else
+# else /* OpenBSD */
     CHECK_ERR(pthread_stackseg_np(pthread_self(), &stk));
 # endif
     *addr = stk.ss_sp;
     *size = stk.ss_size;
-#elif defined HAVE_PTHREAD_GETTHRDS_NP
+#elif defined HAVE_PTHREAD_GETTHRDS_NP /* AIX */
     pthread_t th = pthread_self();
     struct __pthrdsinfo thinfo;
     char reg[256];
@@ -506,6 +510,8 @@
 				   &reg, &regsiz));
     *addr = thinfo.__pi_stackaddr;
     *size = thinfo.__pi_stacksize;
+#else
+#error STACKADDR_AVAILABLE is defined but not implemented.
 #endif
     return 0;
 #undef CHECK_ERR

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

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