public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: Houder <houder@xs4all.nl>
Cc: cygwin@cygwin.com
Subject: Re: Signal delivered while blocked
Date: Sun, 20 Aug 2017 16:16:00 -0000	[thread overview]
Message-ID: <20170820161629.GA4034714@rfd.leadboat.com> (raw)
In-Reply-To: <873ad91db0845b2dffdc65bf8b1e32a2@xs4all.nl>

On Sun, Aug 20, 2017 at 02:18:45PM +0200, Houder wrote:
> On 2017-08-19 10:01, Noah Misch wrote:
> >What words in those chapters prompted your conclusion?  I see nothing in
> >20.10 or 20.13 about contextual restrictions on SIG_SETMASK.  Posix
> >mentions no such restrictions in its sigprocmask() page, and Posix does
> >say:

> Keep in mind, that I replied to your post after I had executed your code on
> Linux (and had a hard look at your code).
> 
> I was astonished to see the 'run-away' stack on Linux ...
> 
> ("that cannot be correct", was my thinking)
> 
> I should have written in my previous reply:
> 
>     "you cannot make use of SIG_SETMASK in sigprocmask() within the context
>      of a handler", IN THE WAY YOU DO IT"
> or
>     "in the body of a signal handler, one cannot modify the signal mask w/o
>      knowing what it was at the beginning"
> 
>  1. when a signal handler is entered, the kernel will (usually) have added
>     the signal number, associated to the handler, to the mask
>  2. the execution of a handler may be nested within the execution of another
> 
> Consequently, one does not know what the signal mask is at the beginning of
> the critical section in the handler.
> 
> That is why you want to save the current signal mask when modifying it (at
> the start of the critical section).
> 
> At the end of the critical section, one should restore the old signal mask,
> or test it in case one want to revert the signal mask "by hand".
> 
> Take a look at listing 20-5 in LPI.

If the test program has undefined behavior according to Posix, I want to know
that.  If the test program can cause $SUBJECT according to Posix, I want to
know that.

Following your advice above would not remove undefined behavior or prevent
$SUBJECT.  It would make the signal-using software more maintainable and
reduce the risk of consuming all stack space.  Those are good goals for
authors to pursue, but this thread is about delivery of blocked signals.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

      reply	other threads:[~2017-08-20 16:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04  7:45 Noah Misch
2017-08-04 17:02 ` Corinna Vinschen
2017-08-04 18:58   ` Kaz Kylheku
2017-08-05  6:40     ` Noah Misch
2017-08-14  6:03 ` Houder
2017-08-14  8:36   ` Signal delivered while blocked (2) Houder
2017-08-19  8:01   ` Signal delivered while blocked Noah Misch
2017-08-20 12:18     ` Houder
2017-08-20 16:16       ` Noah Misch [this message]

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=20170820161629.GA4034714@rfd.leadboat.com \
    --to=noah@leadboat.com \
    --cc=cygwin@cygwin.com \
    --cc=houder@xs4all.nl \
    /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).