public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "E. Madison Bray" <erik.m.bray@gmail.com>
To: cygwin@cygwin.com
Cc: gasnet-devel@lbl.gov, Dan Bonachea <dobonachea@lbl.gov>
Subject: Re: Bug: Incorrect signal behavior in multi-threaded processes
Date: Tue, 22 Jan 2019 11:16:00 -0000	[thread overview]
Message-ID: <CAOTD34bXKQSjbce_+qNb-9GaFu88Q3o_Qw0t4oC9yK4+A7eNiA@mail.gmail.com> (raw)
In-Reply-To: <CAJTO8-bD0jPR3Vyr84Z_4BUdh3pPiZ-9ekeMBFUOFJRn5e0wQQ@mail.gmail.com>

On Sun, Jan 20, 2019 at 9:34 PM Dan Bonachea wrote:
>
> I'm writing to report some POSIX compliance problems with Cygwin
> signal handling in the presence of multiple pthreads that our group
> has encountered in our parallel scientific computing codes.
>
> A minimal test program is copied below and also available here:
> https://upc-bugs.lbl.gov/bugzilla/attachment.cgi?id=589
>
> I believe the test program is fully compliant with ISO C 99 and POSIX
> 1003.1-2016. In a nutshell, it registers one signal handler, spawns a
> number of pthreads, and then synchronously generates a signal from
> exactly one thread while others sit in a pthread_barrier_wait. The
> "throwing" thread and signal number can be varied from the command
> line, and diagnostic output indicates what happened.
>
> As a basis for comparison, here are a few examples of the test program
> running on x86_64/Linux-3.10.0(Scientific Linux 7.4)/gcc-4.8.5
> demonstrating what I believe to be the *correct*/POSIX-required
> behavior:

Thank you for the detailed analysis of this problem.  I haven't
personally encountered a problem like this in any of my own code,
though I'm not relying on pthread_barrier, or signal handlers being
run from specific threads.  This is relevant to my interests though,
so time permitting I might look into it just out of curiosity of
nothing else.  The behavior with SIGSEGV in particular is very
reminiscent (possibly same as) a problem I reported last year, but
never got around to fixing (except for the local workaround I used):
https://cygwin.com/ml/cygwin/2018-05/msg00333.html

I wonder if the same problem applies to thread-local stacks.  Indeed,
I ran your test program in gdb with arguments (1, 11) with a
breakpoint in myfault_altstack_handler [1] and wound up there.  But
since the segfault did not come from Cygwin itself (me.andreas is a
"san" fault handler for the current exception being handled by Cygwin,
but this is only set for exceptions generated by Cygwin itself (with
its __try/__except blocks).  In this case it's 0x0 so the exception is
not handled and the process just runs off into the weeds until it
(quickly) runs out of "vectored continue handlers" and so the process
exits (at the Windows level, without Cygwin controlling its shutdown).

For the other cases I'm not as sure what's going on, but possibly
related problems.

[1] https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/exceptions.cc;h=205ad850e4c7b69954fadd1efe3ae9ff65e5f806;hb=HEAD#l594

--
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

  parent reply	other threads:[~2019-01-22 11:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-20 20:33 Dan Bonachea
2019-01-22  9:13 ` Corinna Vinschen
2019-01-22 11:16 ` E. Madison Bray [this message]
2019-01-22 20:43   ` Dan Bonachea
2019-01-23 12:44     ` E. Madison Bray
2019-01-29 23:22       ` Dan Bonachea
2019-01-30 10:44         ` Corinna Vinschen
2019-01-30 15:48           ` Corinna Vinschen
2019-01-30 21:23             ` Corinna Vinschen
2019-01-31  0:12               ` Dan Bonachea
2019-01-31 19:48                 ` Corinna Vinschen

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=CAOTD34bXKQSjbce_+qNb-9GaFu88Q3o_Qw0t4oC9yK4+A7eNiA@mail.gmail.com \
    --to=erik.m.bray@gmail.com \
    --cc=cygwin@cygwin.com \
    --cc=dobonachea@lbl.gov \
    --cc=gasnet-devel@lbl.gov \
    /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).