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

ruby-changes:26853

From: ko1 <ko1@a...>
Date: Wed, 23 Jan 2013 13:40:30 +0900 (JST)
Subject: [ruby-changes:26853] ko1:r38905 (trunk): * thread_pthread.c (ruby_init_stack): ignore `STACK_END_ADDRESS'

ko1	2013-01-23 13:39:02 +0900 (Wed, 23 Jan 2013)

  New Revision: 38905

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

  Log:
    * thread_pthread.c (ruby_init_stack): ignore `STACK_END_ADDRESS'
      if Ruby interpreter is running on co-routine.
      [Feature #2294]
      https://bugs.ruby-lang.org/issues/2294#note-18

  Modified files:
    trunk/ChangeLog
    trunk/thread_pthread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38904)
+++ ChangeLog	(revision 38905)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jan 23 13:35:37 2013  Koichi Sasada  <ko1@a...>
+
+	* thread_pthread.c (ruby_init_stack): ignore `STACK_END_ADDRESS'
+	  if Ruby interpreter is running on co-routine.
+	  [Feature #2294]
+	  https://bugs.ruby-lang.org/issues/2294#note-18
+
 Wed Jan 23 12:28:22 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* win32/win32.c (rb_w32_spawn, rb_w32_aspawn_flags): check the results
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 38904)
+++ thread_pthread.c	(revision 38905)
@@ -643,6 +643,27 @@ ruby_init_stack(volatile VALUE *addr https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L643
 	native_main_thread.stack_maxsize = space;
 #endif
     }
+
+    /* If addr is out of range of main-thread stack range estimation,  */
+    /* it should be on co-routine (alternative stack). [Feature #2294] */
+    {
+	void *start, *end;
+
+	if (IS_STACK_DIR_UPPER()) {
+	    start = native_main_thread.stack_start;
+	    end = (char *)native_main_thread.stack_start + native_main_thread.stack_maxsize;
+	}
+	else {
+	    start = (char *)native_main_thread.stack_start - native_main_thread.stack_maxsize;
+	    end = native_main_thread.stack_start;
+	}
+
+	if ((void *)addr < start || (void *)addr > end) {
+	    /* out of range */
+	    native_main_thread.stack_start = (VALUE *)addr;
+	    native_main_thread.stack_maxsize = 0; /* unknown */
+	}
+    }
 }
 
 #define CHECK_ERR(expr) \

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

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