On Thu May 11 16:37:50 2023 +0000, Alexandre Julliard wrote:
get_signal_stack() return a value of 16n
signal_stack_size = 0x10000 - 0x3800 is also 16n
so value of stack top is 16n
but on x86_64, value of sp at begin of signal handler must be 16n-8
The signal is sent by the kernel, with the stack pointer set according to the ABI. Please explain on what exact setup you are seeing the problem.
for example, when quit_signal occur, quit_handler be called. but value of sp is 16n instead of 16n-8 at begin of quit_handler. the next instruction is "push %rbp", after the instruction, sp is 16n-8. Currently the quit_handler, there is No problem, ``` static void quit_handler( int signal, siginfo_t *siginfo, void *ucontext ) { // push %rbp init_handler( ucontext ); // sp is 16n-8 abort_thread(0); } ``` But if I add a calling of WINAPI function, For Example
``` extern int bar(void); int WINAPI foo(void) { // callee is Linux API, caller is WINAPI, need save xmm register. xmm value must store to memory which aligned of 16 return bar() + 1; }
static void quit_handler( int signal, siginfo_t *siginfo, void *ucontext ) { // push %rbp foo(); // sp is 16n-8, expected value 16n, problem may occured init_handler( ucontext ); abort_thread(0); } ``` the problem may be occured.
Although no errors will currently occur. If add __attribute__((force_align_arg_pointer))
``` static DECLSPEC_FORCEALIGN void quit_handler( int signal, siginfo_t *siginfo, void *ucontext ) { // push %rbp // and -16, %rsp init_handler( ucontext ); // sp is 16n abort_thread(0); } ```