From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93936 invoked by alias); 22 Jan 2019 11:16:56 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 93889 invoked by uid 89); 22 Jan 2019 11:16:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=interests, wound, controlling, curiosity X-HELO: mail-it1-f181.google.com Received: from mail-it1-f181.google.com (HELO mail-it1-f181.google.com) (209.85.166.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 Jan 2019 11:16:51 +0000 Received: by mail-it1-f181.google.com with SMTP id x124so9407058itd.1 for ; Tue, 22 Jan 2019 03:16:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MHwzb9v3nGzPj77h21vi1REALSjkdtLTAqf5P3GoVXU=; b=lmUn6XeMJRVcVL3+YvwL2LdrrWmsCdp9qkYctTYrfs11mTV4NEvTzUtpegfbL4juOj QUJa0ZzlluqV34CCS3Em8thpaeYBYGr/v0wmuzW0n/863Ns3oRC03gnw8W7/ZxE6edC1 rOfOxYMWDgA0z/dp0eTkdNstRexIBx0FWlxnt6KmZKNmECvC26kD0G56sbsYsCi8PwQz /1PXBhE93qS9+OqenJyUn5xGFWjRTMUpwT+lxUIWVCiEqy2g+EDHpjLIZGJaOYrvXJ+J +sA+XG3lCf1R5YnnDqXUA8WDCCPh82ZWk1oPdY8CXy8bbWcZ9zfuk2sDoWMJPIUB9FNv gkBw== MIME-Version: 1.0 References: In-Reply-To: From: "E. Madison Bray" Date: Tue, 22 Jan 2019 11:16:00 -0000 Message-ID: Subject: Re: Bug: Incorrect signal behavior in multi-threaded processes To: cygwin@cygwin.com Cc: gasnet-devel@lbl.gov, Dan Bonachea Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00177.txt.bz2 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