summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--thread_pthread.c37
-rw-r--r--version.h6
3 files changed, 47 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e42b124395..a009ac25a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Feb 13 03:13:05 2015 Scott Francis <scott.francis@shopify.com>
+
+ * 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]
+
Fri Feb 6 12:05:13 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* thread.c: Improve documentation for Thread#value
diff --git a/thread_pthread.c b/thread_pthread.c
index 7e4d36c479..711e60baf1 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -653,6 +653,42 @@ space_size(size_t stack_size)
}
}
+#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.
*
@@ -674,6 +710,7 @@ ruby_init_stack(volatile VALUE *addr
if (get_main_stack(&stackaddr, &size) == 0) {
native_main_thread.stack_maxsize = size;
native_main_thread.stack_start = stackaddr;
+ reserve_stack(stackaddr, size);
return;
}
}
diff --git a/version.h b/version.h
index a89fb7c2fd..b11a37b359 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.2.0"
-#define RUBY_RELEASE_DATE "2015-02-06"
-#define RUBY_PATCHLEVEL 43
+#define RUBY_RELEASE_DATE "2015-02-13"
+#define RUBY_PATCHLEVEL 44
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 6
+#define RUBY_RELEASE_DAY 13
#include "ruby/version.h"