views:

170

answers:

1

I am using alternate stack to handle signals for program in C over linux. When stack overflow occurs, my signal are delivered on to my alternate signal stack not on the main stack.

So in this situation I want to dump the main stack.... how can I ?

+1  A: 

Hi,

remember the top stack address in main (& of some local variable in that stack frame), and dump from the exception address to that. Be aware, that there are some portability issues (stack grows upward on hp-pa-risc, for example). If the failure was not due to an access into the protected area below the overflowing stack, you have to look at the exception info for the sp which was valid before the signal. The exception info is passed as argument to the signal handler. Again, this is likely to be very cpu and os specific (varies among all unices).

regards

blabla999