summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-29 17:22:04 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-29 17:22:04 +0000
commit50864b9d019e2dfd5fb43c5e4ea50917ba2d3f4a (patch)
tree6c1ec38446a8587525d84d471234246e154d1703 /thread_pthread.c
parent710fe14b5d1e00f9ae2d3fb49670b91a27dbe233 (diff)
merge revision(s) 54256,54291,54292,54293: [Backport #12118] [Bug #12218]
* thread_pthread.c (reserve_stack): fix reserving position where the stack growing bottom to top. [Bug #12118] * localeinit.c (rb_locale_charmap_index): fix prototype. patched by Andreas Schwab [Bug #12218] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 767805119d..1acd56c357 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -693,17 +693,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;
}
}
}