summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-23 02:21:38 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-23 02:21:38 +0000
commitcc8354ba83e311056b2ccf69de0d67aa547afe27 (patch)
treea9a0db909a944316df22dbaf7d897d19dcd141cf
parentf869ed2ff334c78d21aaebf7c359df80593e358c (diff)
merge revision(s) 35978,36013,36014,36015,36052,36076,36487: [Backport #6898]
* thread_pthread.c (ruby_init_stack): use stack info if possible. * thread_pthread.c (ruby_init_stack): adjust stack size for offset of addr from the bottom. * thread_pthread.c (get_stack): seems stack size does not include guard size on Mac OS X. * gc.h (IS_STACK_DIR_UPPER): utility macro. * thread_pthread.c (get_stack): Linux is the only OS which includes the size of guard page into the stack size. * thread_pthread.c (ruby_init_stack): STACK_GROW_DIR_DETECTION is necessary on platforms with unknown stack direction. [Bug #6761] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@36789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog24
-rw-r--r--gc.h1
-rw-r--r--thread_pthread.c43
-rw-r--r--version.h6
4 files changed, 49 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 5fc37e6359..db45f9e3be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+Thu Aug 23 11:19:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * thread_pthread.c (ruby_init_stack): STACK_GROW_DIR_DETECTION is
+ necessary on platforms with unknown stack direction. [Bug #6761]
+
+Thu Aug 23 11:19:51 2012 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * thread_pthread.c (get_stack): Linux is the only OS which includes
+ the size of guard page into the stack size.
+
+Thu Aug 23 11:19:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * gc.h (IS_STACK_DIR_UPPER): utility macro.
+
+ * thread_pthread.c (get_stack): seems stack size does not include
+ guard size on Mac OS X.
+
+ * thread_pthread.c (ruby_init_stack): adjust stack size for offset of
+ addr from the bottom.
+
+Thu Aug 23 11:19:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * thread_pthread.c (ruby_init_stack): use stack info if possible.
+
Mon Aug 20 17:11:01 2012 NARUSE, Yui <naruse@ruby-lang.org>
* file.c (file_path_convert): don't convert it when the path string is
diff --git a/gc.h b/gc.h
index df2cf7dd79..f280a460ed 100644
--- a/gc.h
+++ b/gc.h
@@ -81,6 +81,7 @@ int ruby_get_stack_grow_direction(volatile VALUE *addr);
#define STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection
#define STACK_DIR_UPPER(a,b) STACK_UPPER(&stack_grow_dir_detection, (a), (b))
#endif
+#define IS_STACK_DIR_UPPER() STACK_DIR_UPPER(1,0)
#if defined __GNUC__ && __GNUC__ >= 4
#pragma GCC visibility push(default)
diff --git a/thread_pthread.c b/thread_pthread.c
index eff3d81368..6659972d97 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -477,41 +477,38 @@ get_stack(void **addr, size_t *size)
{
#define CHECK_ERR(expr) \
{int err = (expr); if (err) return err;}
-#if defined HAVE_PTHREAD_GETATTR_NP || defined HAVE_PTHREAD_ATTR_GET_NP || \
- (defined HAVE_PTHREAD_GET_STACKADDR_NP && defined HAVE_PTHREAD_GET_STACKSIZE_NP)
+#ifdef HAVE_PTHREAD_GETATTR_NP /* Linux */
pthread_attr_t attr;
size_t guard = 0;
-
-# ifdef HAVE_PTHREAD_GETATTR_NP /* Linux */
STACK_GROW_DIR_DETECTION;
CHECK_ERR(pthread_getattr_np(pthread_self(), &attr));
-# ifdef HAVE_PTHREAD_ATTR_GETSTACK
+# ifdef HAVE_PTHREAD_ATTR_GETSTACK
CHECK_ERR(pthread_attr_getstack(&attr, addr, size));
STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size));
-# else
+# else
CHECK_ERR(pthread_attr_getstackaddr(&attr, addr));
CHECK_ERR(pthread_attr_getstacksize(&attr, size));
-# endif
-# elif defined HAVE_PTHREAD_ATTR_GET_NP /* FreeBSD, DragonFly BSD, NetBSD */
+# endif
+ CHECK_ERR(pthread_attr_getguardsize(&attr, &guard));
+ *size -= guard;
+ pthread_attr_destroy(&attr);
+#elif defined HAVE_PTHREAD_ATTR_GET_NP /* FreeBSD, DragonFly BSD, NetBSD */
+ pthread_attr_t attr;
CHECK_ERR(pthread_attr_init(&attr));
CHECK_ERR(pthread_attr_get_np(pthread_self(), &attr));
-# ifdef HAVE_PTHREAD_ATTR_GETSTACK
+# ifdef HAVE_PTHREAD_ATTR_GETSTACK
CHECK_ERR(pthread_attr_getstack(&attr, addr, size));
STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size));
-# else
+# else
CHECK_ERR(pthread_attr_getstackaddr(&attr, addr));
CHECK_ERR(pthread_attr_getstacksize(&attr, size));
STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size));
-# endif
-# else /* MacOS X */
+# endif
+ pthread_attr_destroy(&attr);
+#elif (defined HAVE_PTHREAD_GET_STACKADDR_NP && defined HAVE_PTHREAD_GET_STACKSIZE_NP) /* MacOS X */
pthread_t th = pthread_self();
*addr = pthread_get_stackaddr_np(th);
*size = pthread_get_stacksize_np(th);
- CHECK_ERR(pthread_attr_init(&attr));
-# endif
- CHECK_ERR(pthread_attr_getguardsize(&attr, &guard));
- *size -= guard;
- pthread_attr_destroy(&attr);
#elif defined HAVE_THR_STKSEGMENT || defined HAVE_PTHREAD_STACKSEG_NP
stack_t stk;
# if defined HAVE_THR_STKSEGMENT /* Solaris */
@@ -581,16 +578,18 @@ ruby_init_stack(volatile VALUE *addr
{
size_t size = 0;
size_t space = 0;
-#if defined(HAVE_PTHREAD_ATTR_GET_NP)
- void* addr;
- get_stack(&addr, &size);
+#if defined(STACKADDR_AVAILABLE)
+ void* stackaddr;
+ STACK_GROW_DIR_DETECTION;
+ get_stack(&stackaddr, &size);
+ space = STACK_DIR_UPPER((char *)addr - (char *)stackaddr, (char *)stackaddr - (char *)addr);
#elif defined(HAVE_GETRLIMIT)
struct rlimit rlim;
if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
size = (size_t)rlim.rlim_cur;
}
-#endif
space = size > 5 * 1024 * 1024 ? 1024 * 1024 : size / 5;
+#endif
native_main_thread.stack_maxsize = size - space;
}
}
@@ -1310,7 +1309,7 @@ ruby_stack_overflowed_p(const rb_thread_t *th, const void *addr)
}
size /= 5;
if (size > water_mark) size = water_mark;
- if (STACK_DIR_UPPER(1, 0)) {
+ if (IS_STACK_DIR_UPPER()) {
if (size > ~(size_t)base+1) size = ~(size_t)base+1;
if (addr > base && addr <= (void *)((char *)base + size)) return 1;
}
diff --git a/version.h b/version.h
index bf18ef0e0d..92b8bf5382 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 261
+#define RUBY_PATCHLEVEL 262
-#define RUBY_RELEASE_DATE "2012-08-20"
+#define RUBY_RELEASE_DATE "2012-08-23"
#define RUBY_RELEASE_YEAR 2012
#define RUBY_RELEASE_MONTH 8
-#define RUBY_RELEASE_DAY 20
+#define RUBY_RELEASE_DAY 23
#include "ruby/version.h"