From 60e85501f20d6992a4dbf0b1930e87cfdf642295 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 27 Jan 2014 12:53:48 +0000 Subject: 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 --- thread_pthread.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'thread_pthread.c') 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 -- cgit v1.2.3