summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--thread_pthread.c26
-rw-r--r--version.h2
3 files changed, 26 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 7fa69fe646..5ba31484a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Mar 30 06:11:36 2016 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * thread_pthread.c (reserve_stack): fix reserving position where
+ the stack growing bottom to top. [Bug #12118]
+
Wed Mar 30 06:04:18 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* .travis.yml: removed commented-out code.
diff --git a/thread_pthread.c b/thread_pthread.c
index d3162993b8..224305819e 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -680,17 +680,31 @@ reserve_stack(volatile char *limit, size_t size)
const volatile char *end = buf + sizeof(buf);
limit += size;
if (limit > end) {
- size = limit - end;
- limit = alloca(size);
- limit[stack_check_margin+size-1] = 0;
+ /* |<-bottom (=limit(a)) top->|
+ * | .. |<-buf 256B |<-end | stack check |
+ * | 256B | =size= | margin (4KB)|
+ * | =size= limit(b)->| 256B | |
+ * | | alloca(sz) | | |
+ * | .. |<-buf |<-limit(c) [sz-1]->0> | |
+ */
+ size_t sz = limit - end;
+ limit = alloca(sz);
+ limit[sz-1] = 0;
}
}
else {
limit -= size;
if (buf > limit) {
- limit = alloca(buf - limit);
- limit[0] = 0; /* ensure alloca is called */
- limit -= stack_check_margin;
+ /* |<-top (=limit(a)) bottom->|
+ * | .. | 256B buf->| | stack check |
+ * | 256B | =size= | margin (4KB)|
+ * | =size= limit(b)->| 256B | |
+ * | | alloca(sz) | | |
+ * | .. | buf->| limit(c)-><0> | |
+ */
+ size_t sz = buf - limit;
+ limit = alloca(sz);
+ limit[0] = 0;
}
}
}
diff --git a/version.h b/version.h
index 6641beb2c6..219d09281a 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.5"
#define RUBY_RELEASE_DATE "2016-03-30"
-#define RUBY_PATCHLEVEL 288
+#define RUBY_PATCHLEVEL 289
#define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 3