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

ruby-changes:38208

From: usa <ko1@a...>
Date: Mon, 13 Apr 2015 17:02:57 +0900 (JST)
Subject: [ruby-changes:38208] usa:r50289 (ruby_2_1): merge revision(s) 49452: [Backport #10813]

usa	2015-04-13 17:02:39 +0900 (Mon, 13 Apr 2015)

  New Revision: 50289

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

  Log:
    merge revision(s) 49452: [Backport #10813]
    
    * thread_pthread.c (reserve_stack): fix intermittent SIGBUS on
      Linux, by reserving the stack virtual address space at process
      start up so that it will not clash with the heap space.
      [Fix GH-822]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/thread_pthread.c
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 50288)
+++ ruby_2_1/ChangeLog	(revision 50289)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Mon Apr 13 17:02:25 2015  Scott Francis  <scott.francis@s...>
+
+	* thread_pthread.c (reserve_stack): fix intermittent SIGBUS on
+	  Linux, by reserving the stack virtual address space at process
+	  start up so that it will not clash with the heap space.
+	  [Fix GH-822]
+
 Mon Apr 13 16:52:14 2015  Koichi Sasada  <ko1@a...>
 
 	* class.c (rb_prepend_module): need a WB for klass -> origin.
Index: ruby_2_1/thread_pthread.c
===================================================================
--- ruby_2_1/thread_pthread.c	(revision 50288)
+++ ruby_2_1/thread_pthread.c	(revision 50289)
@@ -648,6 +648,42 @@ space_size(size_t stack_size) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/thread_pthread.c#L648
     }
 }
 
+#ifdef __linux__
+static __attribute__((noinline)) void
+reserve_stack(volatile char *limit, size_t size)
+{
+# ifdef C_ALLOCA
+#   error needs alloca()
+# endif
+    struct rlimit rl;
+    volatile char buf[0x100];
+    STACK_GROW_DIR_DETECTION;
+
+    if (!getrlimit(RLIMIT_STACK, &rl) && rl.rlim_cur == RLIM_INFINITY)
+	return;
+
+    size -= sizeof(buf); /* margin */
+    if (IS_STACK_DIR_UPPER()) {
+	const volatile char *end = buf + sizeof(buf);
+	limit += size;
+	if (limit > end) {
+	    size = limit - end;
+	    limit = alloca(size);
+	    limit[size-1] = 0;
+	}
+    }
+    else {
+	limit -= size;
+	if (buf > limit) {
+	    limit = alloca(buf - limit);
+	    limit[0] = 0;
+	}
+    }
+}
+#else
+# define reserve_stack(limit, size) ((void)(limit), (void)(size))
+#endif
+
 #undef ruby_init_stack
 /* Set stack bottom of Ruby implementation.
  *
@@ -669,6 +705,7 @@ ruby_init_stack(volatile VALUE *addr https://github.com/ruby/ruby/blob/trunk/ruby_2_1/thread_pthread.c#L705
 	if (get_main_stack(&stackaddr, &size) == 0) {
 	    native_main_thread.stack_maxsize = size;
 	    native_main_thread.stack_start = stackaddr;
+	    reserve_stack(stackaddr, size);
 	    return;
 	}
     }
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 50288)
+++ ruby_2_1/version.h	(revision 50289)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.5"
 #define RUBY_RELEASE_DATE "2015-04-13"
-#define RUBY_PATCHLEVEL 332
+#define RUBY_PATCHLEVEL 333
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 4

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r49452


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

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