[haiku-bugs] Re: [Haiku] #10509: Stack is not aligned

  • From: "pulkomandy" <trac@xxxxxxxxxxxx>
  • Date: Mon, 17 Feb 2014 19:00:50 -0000

#10509: Stack is not aligned
-----------------------------+----------------------------
   Reporter:  pulkomandy     |      Owner:  axeld
       Type:  enhancement    |     Status:  new
   Priority:  normal         |  Milestone:  R1/alpha5
  Component:  System/Kernel  |    Version:  R1/Development
 Resolution:                 |   Keywords:
 Blocked By:                 |   Blocking:
Has a Patch:  0              |   Platform:  x86
-----------------------------+----------------------------

Comment (by pulkomandy):

 Sorry, I'm not too familiar with this code. Modifying
 {{{arch_randomize_stack_pointer}}} is ok. However, in
 {{{arch_thread_enter_userspace}}}, the stackTop is decremented by12
 already, as the "args" are pushed on the stack. Wouldn't that break the
 alignment?

 In the current code, it means we get {{{stackTop % 16 == 4}}}, and
 modifying {{{arch_randomize_stack_pointer}}} to substract 4 from the
 aligned value would lead to {{{stackTop % 16 == 0}}} after the push. Still
 not what we want. If I change {{{arch_randomize_stack_pointer}}} so the
 alignment gets correct after the push, then get_signal_stack, which
 doesn't appear to push anything, would be misaligned.

 I'm not sure how to adjust the stack size, either. Callers use
 {{{thread->signal_stack_size}}} and {{{thread->signal_stack_base}}}, and
 the respective {{{user_}}} fields. These are allocated in
 {{{create_thread_user_stack}}}, and may even be provided by the user. Is
 it needed to increase the stack size there, or is it acceptable to lose
 some bytes because of the alignment without adjusting it?

--
Ticket URL: <https://dev.haiku-os.org/ticket/10509#comment:5>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: