public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: libc-alpha@sourceware.org
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>, 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	[thread overview]
Message-ID: <20230522180511.2132257-1-samuel.thibault@ens-lyon.org> (raw)

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.  */
-- 
2.39.2


                 reply	other threads:[~2023-05-22 18:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230522180511.2132257-1-samuel.thibault@ens-lyon.org \
    --to=samuel.thibault@ens-lyon.org \
    --cc=commit-hurd@gnu.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).