ruby-changes:48269
From: normal <ko1@a...>
Date: Tue, 24 Oct 2017 06:50:15 +0900 (JST)
Subject: [ruby-changes:48269] normal:r60384 (trunk): thread_pthread: do not corrupt stack
normal 2017-10-24 06:50:08 +0900 (Tue, 24 Oct 2017) New Revision: 60384 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60384 Log: 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] Modified files: trunk/thread_pthread.c Index: thread_pthread.c =================================================================== --- thread_pthread.c (revision 60383) +++ thread_pthread.c (revision 60384) @@ -836,8 +836,9 @@ native_thread_init_stack(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L836 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) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/