From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS197226 156.67.106.0/24 X-Spam-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, RCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_ZBI,RCVD_IN_XBL,RDNS_NONE,SPF_FAIL, SPF_HELO_FAIL shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from 80x24.org (unknown [156.67.106.30]) by dcvr.yhbt.net (Postfix) with ESMTP id 2DC3020A26 for ; Thu, 28 Sep 2017 00:42:42 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH 2/3] thread_pthread: do not corrupt stack Date: Thu, 28 Sep 2017 00:42:27 +0000 Message-Id: <20170928004228.4538-2-e@80x24.org> In-Reply-To: <20170928004228.4538-1-e@80x24.org> References: <20170928004228.4538-1-e@80x24.org> List-Id: [ruby-core:82737] [Bug #13387] --- thread_pthread.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/thread_pthread.c b/thread_pthread.c index 96723d4b17..d70bd265d6 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -841,8 +841,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) { -- EW