aboutsummaryrefslogtreecommitdiffstats
path: root/thread_pthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c8
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