[PATCH] Only construct ucontext for SA_SIGINFO signal handlers
Corinna Vinschen
corinna-cygwin@cygwin.com
Fri Apr 3 11:18:00 GMT 2015
On Apr 2 20:30, Jon TURNEY wrote:
> * exceptions.cc (call_signal_handler): Only bother to construct
> the ucontext for signal handlers with SA_SIGINFO set.
Looks good, except...
> + ucontext_t context;
> + ucontext_t *thiscontext = NULL;
> +
> + /* 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)
> + memcpy (&context.uc_mcontext, ((cygwin_exception *)thissi.si_cyg)->context(), sizeof(CONTEXT));
> + else
> + RtlCaptureContext ((CONTEXT *)&context.uc_mcontext);
> + /* FIXME: Really this should be the context which the signal interrupted? */
> +
> + /* FIXME: If/when sigaltstack is implemented, this will need to do
> + something more complicated */
> + context.uc_stack.ss_sp = NtCurrentTeb ()->Tib.StackBase;
> + context.uc_stack.ss_flags = 0;
> + if (!NtCurrentTeb ()->DeallocationStack)
> + context.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->Tib.StackLimit - (uintptr_t)NtCurrentTeb ()->Tib.StackBase;
> + else
> + context.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->DeallocationStack - (uintptr_t)NtCurrentTeb ()->Tib.StackBase;
> +
> + thiscontext = &context;
> + }
> sigset_t this_oldmask = set_process_mask_delta ();
> - thiscontext.uc_sigmask = this_oldmask;
> + context.uc_sigmask = this_oldmask;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This call to set_process_mask_delta() should occur before constructing
the context, so that filling in uc_sigmask can be moved into the above
`'if' branch.
On second thought, isn't this slightly wrong anyway? Shouldn't that be
context.uc_sigmask = _my_tls.sigmask;
context.uc_mcontext.oldmask = this_oldmask;
?
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20150403/8772fe40/attachment.sig>
More information about the Cygwin-patches
mailing list