diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | test/ruby/test_exception.rb | 10 | ||||
-rw-r--r-- | thread_pthread.c | 8 |
3 files changed, 30 insertions, 0 deletions
@@ -1,3 +1,15 @@ +Mon Jan 27 21:53:45 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * 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] + +Mon Jan 27 21:52:55 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * 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] + Sat Jan 25 22:17:02 2014 Kazuhiro NISHIYAMA <zn@mbf.nifty.com> * README.ja.md, README.md: update the controller address of diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index f15b37f8b9..32f97fa1aa 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -488,6 +488,16 @@ end.join rescue SystemStackError end + def test_machine_stackoverflow_by_define_method + bug9454 = '[ruby-core:60113] [Bug #9454]' + assert_separately([], <<-SRC) + assert_raise(SystemStackError, #{bug9454.dump}) { + define_method(:foo) {self.foo} + self.foo + } + SRC + end + def test_cause msg = "[Feature #8257]" cause = nil 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 |