public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH] Only construct ucontext for SA_SIGINFO signal handlers
Date: Fri, 03 Apr 2015 11:18:00 -0000	[thread overview]
Message-ID: <20150403111806.GO13285@calimero.vinschen.de> (raw)
In-Reply-To: <1428003041-14404-1-git-send-email-jon.turney@dronecode.org.uk>

[-- Attachment #1: Type: text/plain, Size: 2133 bytes --]

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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-04-03 11:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 19:30 Jon TURNEY
2015-04-03 11:18 ` Corinna Vinschen [this message]
2015-04-03 12:17   ` Corinna Vinschen
2015-04-03 12:51     ` Jon TURNEY
2015-04-03 14:08       ` Corinna Vinschen
2015-04-04 16:07         ` Jon TURNEY

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150403111806.GO13285@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).