1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2014-01-27 12:53:48 +00:00
parent 4f63c763ad
commit 60e85501f2
3 changed files with 30 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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