From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1792) id 44CEE3858C78; Mon, 22 May 2023 18:04:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 44CEE3858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684778696; bh=pjdXVCr6nl0MPRorBkVa5z+ryoQQ0CABSOkya2EEq4U=; h=From:To:Subject:Date:From; b=w5TQm55/lQb7ibRziYcDV8AdqWwMY3oibIBOLFehRuD1nPkf63XMlt5usU4vxmpIk akzE/euebPGTq7ndzhhqrThVgDOp6sV495lwaJev+Xkm+zHRV7BSaeeiH+iLa+K9vB quyT+Zp74vCn42dqO3MsZuHwCbYxfQWXIuNahr2Y= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Samuel Thibault To: glibc-cvs@sourceware.org Subject: [glibc] mach: Fix mach_setup_thread_impl with NULL stack_base X-Act-Checkin: glibc X-Git-Author: Samuel Thibault X-Git-Refname: refs/heads/master X-Git-Oldrev: ea08d8dceab27ef464b9c00a03b5c61a741a634d X-Git-Newrev: ea752260cc40ab3411d841cb5ece8df66b27add4 Message-Id: <20230522180456.44CEE3858C78@sourceware.org> Date: Mon, 22 May 2023 18:04:56 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ea752260cc40ab3411d841cb5ece8df66b27add4 commit ea752260cc40ab3411d841cb5ece8df66b27add4 Author: Samuel Thibault Date: Mon May 22 17:47:49 2023 +0000 mach: Fix mach_setup_thread_impl with NULL stack_base This is notably necessary for running the gmon thread. Diff: --- mach/setup-thread.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mach/setup-thread.c b/mach/setup-thread.c index 0e149787f8..af16d6cb84 100644 --- a/mach/setup-thread.c +++ b/mach/setup-thread.c @@ -33,7 +33,7 @@ mach_setup_thread_impl (task_t task, thread_t thread, int is_call, kern_return_t error; struct machine_thread_state ts; mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT; - vm_address_t stack; + vm_address_t stack, stack_start; vm_size_t size; int anywhere; @@ -51,22 +51,22 @@ mach_setup_thread_impl (task_t task, thread_t thread, int is_call, *stack_size = size; #ifdef STACK_GROWTH_DOWN - if (stack_base) - *stack_base = stack + __vm_page_size; + stack_start = stack + __vm_page_size; #elif defined (STACK_GROWTH_UP) - if (stack_base) - *stack_base = stack; + stack_start = stack; stack += size; #else #error stack direction unknown #endif + if (stack_base) + *stack_base = stack_start; if (is_call) - MACHINE_THREAD_STATE_SETUP_CALL (&ts, *stack_base, size, pc); + MACHINE_THREAD_STATE_SETUP_CALL (&ts, stack_start, size, pc); else { MACHINE_THREAD_STATE_SET_PC (&ts, pc); - MACHINE_THREAD_STATE_SET_SP (&ts, *stack_base, size); + MACHINE_THREAD_STATE_SET_SP (&ts, stack_start, size); } /* Create the red zone. */