Only construct ucontext for SA_SIGINFO signal handlers
* exceptions.cc (call_signal_handler): Only bother to construct the ucontext for signal handlers with SA_SIGINFO set. Set mcontext.oldmask. Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
This commit is contained in:
parent
65c071bc4d
commit
9043956ce8
|
@ -1,3 +1,9 @@
|
||||||
|
2015-04-02 Jon TURNEY <jon.turney@dronecode.org.uk>
|
||||||
|
|
||||||
|
* exceptions.cc (call_signal_handler): Only bother to construct
|
||||||
|
the ucontext for signal handlers with SA_SIGINFO set. Set
|
||||||
|
mcontext.oldmask.
|
||||||
|
|
||||||
2015-04-04 Jon TURNEY <jon.turney@dronecode.org.uk>
|
2015-04-04 Jon TURNEY <jon.turney@dronecode.org.uk>
|
||||||
|
|
||||||
* exceptions.cc (call_signal_handler): Zero initialize context and set
|
* exceptions.cc (call_signal_handler): Zero initialize context and set
|
||||||
|
|
|
@ -1485,42 +1485,52 @@ _cygtls::call_signal_handler ()
|
||||||
debug_only_printf ("dealing with signal %d", sig);
|
debug_only_printf ("dealing with signal %d", sig);
|
||||||
this_sa_flags = sa_flags;
|
this_sa_flags = sa_flags;
|
||||||
|
|
||||||
|
sigset_t this_oldmask = set_process_mask_delta ();
|
||||||
|
|
||||||
/* Save information locally on stack to pass to handler. */
|
/* Save information locally on stack to pass to handler. */
|
||||||
int thissig = sig;
|
int thissig = sig;
|
||||||
siginfo_t thissi = infodata;
|
siginfo_t thissi = infodata;
|
||||||
void (*thisfunc) (int, siginfo_t *, void *) = func;
|
void (*thisfunc) (int, siginfo_t *, void *) = func;
|
||||||
|
|
||||||
ucontext_t thiscontext;
|
ucontext_t context;
|
||||||
thiscontext.uc_link = 0;
|
ucontext_t *thiscontext = NULL;
|
||||||
thiscontext.uc_flags = 0;
|
|
||||||
|
/* Only make a context for SA_SIGINFO handlers */
|
||||||
|
if (this_sa_flags & SA_SIGINFO)
|
||||||
|
{
|
||||||
|
context.uc_link = 0;
|
||||||
|
context.uc_flags = 0;
|
||||||
if (thissi.si_cyg)
|
if (thissi.si_cyg)
|
||||||
memcpy (&thiscontext.uc_mcontext, ((cygwin_exception *)thissi.si_cyg)->context(), sizeof(CONTEXT));
|
memcpy (&context.uc_mcontext, ((cygwin_exception *)thissi.si_cyg)->context(), sizeof(CONTEXT));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* FIXME: Really this should be the context which the signal interrupted? */
|
/* FIXME: Really this should be the context which the signal interrupted? */
|
||||||
memset(&thiscontext.uc_mcontext, 0, sizeof(struct __mcontext));
|
memset(&context.uc_mcontext, 0, sizeof(struct __mcontext));
|
||||||
thiscontext.uc_mcontext.ctxflags = CONTEXT_FULL;
|
context.uc_mcontext.ctxflags = CONTEXT_FULL;
|
||||||
RtlCaptureContext ((CONTEXT *)&thiscontext.uc_mcontext);
|
RtlCaptureContext ((CONTEXT *)&context.uc_mcontext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: If/when sigaltstack is implemented, this will need to do
|
/* FIXME: If/when sigaltstack is implemented, this will need to do
|
||||||
something more complicated */
|
something more complicated */
|
||||||
thiscontext.uc_stack.ss_sp = NtCurrentTeb ()->Tib.StackBase;
|
context.uc_stack.ss_sp = NtCurrentTeb ()->Tib.StackBase;
|
||||||
thiscontext.uc_stack.ss_flags = 0;
|
context.uc_stack.ss_flags = 0;
|
||||||
if (!NtCurrentTeb ()->DeallocationStack)
|
if (!NtCurrentTeb ()->DeallocationStack)
|
||||||
thiscontext.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->Tib.StackLimit - (uintptr_t)NtCurrentTeb ()->Tib.StackBase;
|
context.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->Tib.StackLimit - (uintptr_t)NtCurrentTeb ()->Tib.StackBase;
|
||||||
else
|
else
|
||||||
thiscontext.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->DeallocationStack - (uintptr_t)NtCurrentTeb ()->Tib.StackBase;
|
context.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->DeallocationStack - (uintptr_t)NtCurrentTeb ()->Tib.StackBase;
|
||||||
|
|
||||||
|
context.uc_sigmask = context.uc_mcontext.oldmask = this_oldmask;
|
||||||
|
|
||||||
|
thiscontext = &context;
|
||||||
|
}
|
||||||
|
|
||||||
sigset_t this_oldmask = set_process_mask_delta ();
|
|
||||||
thiscontext.uc_sigmask = this_oldmask;
|
|
||||||
int this_errno = saved_errno;
|
int this_errno = saved_errno;
|
||||||
reset_signal_arrived ();
|
reset_signal_arrived ();
|
||||||
incyg = false;
|
incyg = false;
|
||||||
sig = 0; /* Flag that we can accept another signal */
|
sig = 0; /* Flag that we can accept another signal */
|
||||||
unlock (); /* unlock signal stack */
|
unlock (); /* unlock signal stack */
|
||||||
|
|
||||||
thisfunc (thissig, &thissi, &thiscontext);
|
thisfunc (thissig, &thissi, thiscontext);
|
||||||
incyg = true;
|
incyg = true;
|
||||||
|
|
||||||
set_signal_mask (_my_tls.sigmask, this_oldmask);
|
set_signal_mask (_my_tls.sigmask, this_oldmask);
|
||||||
|
|
Loading…
Reference in New Issue