From patchwork Mon May 22 18:05:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1784603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QQ52x1VzBz20PY for ; Tue, 23 May 2023 04:05:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F0A83857702 for ; Mon, 22 May 2023 18:05:26 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 1552E3858D35 for ; Mon, 22 May 2023 18:05:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1552E3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 3525C20193; Mon, 22 May 2023 20:05:11 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WOZC5ZXXLvan; Mon, 22 May 2023 20:05:11 +0200 (CEST) Received: from begin (lfbn-bor-1-1163-184.w92-158.abo.wanadoo.fr [92.158.138.184]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 0DDDE2015D; Mon, 22 May 2023 20:05:11 +0200 (CEST) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1q19uB-008whQ-1q; Mon, 22 May 2023 20:05:11 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited] mach: Fix mach_setup_thread_impl with NULL stack_base Date: Mon, 22 May 2023 20:05:11 +0200 Message-Id: <20230522180511.2132257-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This is notably necessary for running the gmon thread. --- 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. */