aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-27 12:53:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-27 12:53:48 +0000
commit60e85501f20d6992a4dbf0b1930e87cfdf642295 (patch)
tree22a0b2e1f9c4de9459dc291e28d3da623f99ac82
parent4f63c763ad56dc40d3b9891f2009aab3fc97cc58 (diff)
downloadruby-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
-rw-r--r--ChangeLog12
-rw-r--r--test/ruby/test_exception.rb10
-rw-r--r--thread_pthread.c8
3 files changed, 30 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 5369c989b8..d6a636e72c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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