aboutsummaryrefslogtreecommitdiffstats
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-23 21:50:08 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-23 21:50:08 +0000
commitb6241b20bcf435e3f80ac493bfefba06dcf2abd5 (patch)
treeb8aa261af51017b72a7bbf57277b02601d4b9950 /thread_pthread.c
parent50ac6d6f32fd47f52c0b307a665c37da13643a02 (diff)
downloadruby-b6241b20bcf435e3f80ac493bfefba06dcf2abd5.tar.gz
thread_pthread: do not corrupt stack
This fixes stuck test/ruby/test_io.rb with FIBER_USE_NATIVE=0 on GNU/Linux because linked-list pointers used by glibc get corrupted when fiber stacks are copied. Thanks to wanabe for finding the bug and original patch. * thread_pthread (native_thread_init_stack): fix stack corruption [ruby-core:82737] [Bug #13387] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 0a3fee373d..83eb721a76 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -836,8 +836,9 @@ native_thread_init_stack(rb_thread_t *th)
size_t size;
if (get_stack(&start, &size) == 0) {
- th->ec.machine.stack_start = start;
- th->ec.machine.stack_maxsize = size;
+ uintptr_t diff = (uintptr_t)start - (uintptr_t)&curr;
+ th->ec.machine.stack_start = (VALUE *)&curr;
+ th->ec.machine.stack_maxsize = size - diff;
}
#elif defined get_stack_of
if (!th->ec.machine.stack_maxsize) {