Fix ucontext creation in call_signal handler

* exceptions.cc (__unwind_single_frame): Define empty macro on i686.
        (_cygtls::call_signal_handler): Try to make sure signal context makes
        sense in case we're generating context here.  Add comment to explain.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2015-07-17 18:29:52 +02:00
parent 16d2d9f131
commit b2df1577c7
2 changed files with 21 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2015-07-17 Corinna Vinschen <corinna@vinschen.de>
* exceptions.cc (__unwind_single_frame): Define empty macro on i686.
(_cygtls::call_signal_handler): Try to make sure signal context makes
sense in case we're generating context here. Add comment to explain.
2015-07-17 Corinna Vinschen <corinna@vinschen.de> 2015-07-17 Corinna Vinschen <corinna@vinschen.de>
* exceptions.cc (getcontext/x86_64): Drop comment on RtlCaptureContext. * exceptions.cc (getcontext/x86_64): Drop comment on RtlCaptureContext.

View File

@ -300,6 +300,8 @@ __unwind_single_frame (PCONTEXT ctx)
ctx->Rsp += 8; ctx->Rsp += 8;
} }
} }
#else
#define __unwind_single_frame(ctx)
#endif #endif
/* Walk the stack. /* Walk the stack.
@ -1667,11 +1669,20 @@ _cygtls::call_signal_handler ()
sizeof (CONTEXT)); sizeof (CONTEXT));
else else
{ {
/* FIXME: Really this should be the context which the signal /* Software-generated signal. We're fetching the current
interrupted? */ context, unwind to the caller and in case we're called
memset(&context.uc_mcontext, 0, sizeof (struct __mcontext)); from sigdelayed, fix rip/eip accordingly. */
context.uc_mcontext.ctxflags = CONTEXT_FULL; context.uc_mcontext.ctxflags = CONTEXT_FULL;
RtlCaptureContext ((CONTEXT *) &context.uc_mcontext); RtlCaptureContext ((PCONTEXT) &context.uc_mcontext);
__unwind_single_frame ((PCONTEXT) &context.uc_mcontext);
if (stackptr > stack)
{
#ifdef __x86_64__
context.uc_mcontext.rip = retaddr ();
#else
context.uc_mcontext.eip = retaddr ();
#endif
}
} }
if (this_sa_flags & SA_ONSTACK if (this_sa_flags & SA_ONSTACK