[前][次][番号順一覧][スレッド一覧]

ruby-changes:32633

From: nobu <ko1@a...>
Date: Mon, 27 Jan 2014 21:53:55 +0900 (JST)
Subject: [ruby-changes:32633] nobu:r44712 (trunk): thread_pthread.c: get current main thread stack size

nobu	2014-01-27 21:53:48 +0900 (Mon, 27 Jan 2014)

  New Revision: 44712

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44712

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_exception.rb
    trunk/thread_pthread.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44711)
+++ ChangeLog	(revision 44712)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jan 27 21:53:45 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
+
+	* 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@m...>
 
 	* README.ja.md, README.md: update the controller address of
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 44711)
+++ thread_pthread.c	(revision 44712)
@@ -1562,6 +1562,14 @@ ruby_stack_overflowed_p(const rb_thread_ https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1562
 
     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
Index: test/ruby/test_exception.rb
===================================================================
--- test/ruby/test_exception.rb	(revision 44711)
+++ test/ruby/test_exception.rb	(revision 44712)
@@ -488,6 +488,16 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L488
   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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]