diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-27 12:53:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-27 12:53:48 +0000 |
commit | 60e85501f20d6992a4dbf0b1930e87cfdf642295 (patch) | |
tree | 22a0b2e1f9c4de9459dc291e28d3da623f99ac82 /thread_pthread.c | |
parent | 4f63c763ad56dc40d3b9891f2009aab3fc97cc58 (diff) | |
download | ruby-60e85501f20d6992a4dbf0b1930e87cfdf642295.tar.gz |
thread_pthread.c: get current main thread stack size
* thread_pthread.c: get current main thread stack size, which may
be expanded than allocated size at initialization, by rlimit().
[ruby-core:60113] [Bug #9454]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index cf0e3705af..20c94d9185 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1562,6 +1562,14 @@ ruby_stack_overflowed_p(const rb_thread_t *th, const void *addr) if (th) { size = th->machine_stack_maxsize; +#if defined(HAVE_GETRLIMIT) && MAINSTACKADDR_AVAILABLE + if (pthread_equal(th->thread_id, native_main_thread.id)) { + struct rlimit rlim; + if (getrlimit(RLIMIT_STACK, &rlim) == 0 && rlim.rlim_cur > size) { + size = rlim.rlim_cur; + } + } +#endif base = (char *)th->machine_stack_start - STACK_DIR_UPPER(0, size); } #ifdef STACKADDR_AVAILABLE |