|
From: Eric P. <eri...@wa...> - 2006-02-11 20:23:25
|
> My understanding is: > > - in main, the segfault happens > > - kernel pushes a signal frame on the stack, saving the machine state > in it, and enters handler_new > > - handler_new finds out what %esp was at the time of the fault > (stack = ctx->uc_mcontext.gregs[REG_ESP]). > > My picture of the stack is now > > ------------ > frame for main() > ------------ <--- "stack" > kernel-constructed sigframe ... > ... > kernel-constructed sigframe ... > > - You then do "stack--", which moves "stack" down one frame unit. Now > it overlaps with the kernel-constructed sigframe. No... the signal handler is called on a different stack than the one the thread... (sigaction is called with SA_ONSTACK flag) We push the stack structure on the thread's stack, not the sigaltstack Furthermore, since the stack grows downwards, it's actually pushed onto the thread's stack, as if the thread had called the function itself, and doesn't trash any data on the stack. A+ -- Eric Pouech |